So last weekend I wrote Bench (repo) that's hopefully simpler enough to get used more.
To benchmark your program, just type:
perl -MBench yourscript.pl
. Sample output:$ perl -Ilib -MBench -MMoose -e1
0.229s
Bench exports a single function, bench(), by default. To time a single sub, use:
perl -MBench -e'bench sub { ... }'
. By default it will call your sub at most 100 times or 1 second. Here's a sample output:100 calls (12120/s), 0.0083s (0.0825ms/call)
To benchmark several subs:
perl -MBench -e'bench {a=>sub{...}, b=>sub{...}}'
or perl -MBench -e'bench [sub{...}, sub{...}]'
. Sample output:a: 100 calls (12120/s), 0.0083s (0.0825ms/call)
b: 100 calls (5357/s), 0.0187s (0.187ms/call)
Bench will automatically use Dumbbench if it's already loaded, e.g.:
perl -MDumbbench -MBench -e'...'
. Or you can force Bench to use Dumbbench: perl -MBench -e'bench sub { ... }, {dumbbench=>1}'
.That's about it currently.