use Benchmark;

# timeit():  run $count iterations of the given Perl code, and time it
$t = timeit($count, 'code');  # $t is now a Benchmark object

# timestr():  convert Benchmark times to printable strings
print "$count loops of 'code' took:", timestr($t), "\n";

# timediff():  calculate the difference between two times
$t = timediff($t1 - $t2);

# timethis():  run "code" $count times with timeit(); also, print out a
#     header saying "timethis $count: "
$t = timethis($count, "code");

# timethese():  run timethis() on multiple chunks of code
@t = timethese($count, {
    'Name1' => '...code1...',
    'Name2' => '...code2...',
});

# new method:  return the current time
$t0 = new Benchmark;
# ... your code here ...
$t1 = new Benchmark;
$td = timediff($t1, $t0);
print "the code took:", timestr($dt), "\n";

# debug method:  enable or disable debugging
Benchmark->debug(1);
$t = timeit(10, ' 5 ** $Global ');
Benchmark->debug(0);
*****
$ perl -MBenchmark -Minteger
timethese(100000, { add => '$i += 2', inc => '$i++; $i++' });
<CTRL-D>
Benchmark: timing 1000000 iterations of add, inc...
       add:  4 secs ( 4.52 usr  0.00 sys =  4.52 cpu)
       inc:  6 secs ( 5.32 usr  0.00 sys =  5.32 cpu)
*****
timeit()
timethis()
timethese()
timediff()
timestr()
*****
clearcache()     # clear just the cache element indexed by $key
clearallcache()  # clear the entire cache
disablecache()   # do not use the cache
enablecache()    # resume caching
*****
clearcache($key);
clearallcache();
disablecache();
enablecache();