--Boundary-00=_4qIKBAMkjo+ZGFc Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline
Moin, this is something that I had a long time sitting on my harddisk. I uploaded v0.10 to http://bloodgate.com/perl/packages/BigBench-0.10.tar.gz This is a small script that makes benchmarking different module or even Perl versions against eachother much easier. BigBench v0.10 (c) Copyright by Tels 2001-2002. Have fun! Usage : ./bb [options] Options: --help print this screen and exit --accuracy=digits round results to so many digits --base=number print relative summary based on number --code=sourcecode bench code snippet and ignore definitions --definitons=file from where to read benchmark definitions --duration=seconds run each op for at least this time --nosummary don't print summary --nointeger don't round results to integer --nounlink don't unlink temporary files (for debug) --path=libpath path to libraries used by templates --runs=number run benchmark more than once (see --take) --simulate=sr simulate results by using srand(sr) --skew=factor scale reported numbers by factor --take=run take lowest|average|highest|last --templates=path path to templates to be used --terse terse summary (unless --nosummary) --tight more tight summary (smaller spacing) Options may be abbreviated, their case does not matter. Examples: ./bb --def=math.def --terse --skew=2.1 # better printable? ./bb --def=str.def --inc=math --duration=5 # really fine-grained ./bb --def=some.def --nosummary # detailed ./bb --def=some.def --terse --base=100 # simulate perlbench ./bb --code='"ababba" =~ /a+/;' # only this ./bb --runs=2 --take=last # cache, then bench Here is an excerpt from a definition file, specifiying four ops to benchmark: group=bcmp#0#Big integer bcmp 0#1 1#$x=$c->new('1');$y=$x->copy();##$x->bcmp($y); 0#1e10 1e10#$x=$c->new('1'x10);$y=$x->copy();##$x->bcmp($y); group=bsqrt#0#Big integer square root 0#5#$x=$c->new('5');#$x->copy();#$x->copy()->bsqrt(); 0#12#$x=$c->new('12');#$x->copy();#$x->copy()->bsqrt(); The latter two benchmark the copy() seperately from the copy()->bsqrt() to determine how much the bsqrt() takes alone. The copy() is neccessary to always bench the same bsqrt() operations (it would change $x otherwise). I also attached two template files that do the actual benchmarking. First they make sure that the proper modules are loaded, then setup the opration (notable "$c" because our definition file will use this). Of course, you can also just benchmark any code snippet: ./bb --code='$a =~ /abc/' The biggst TODO is currently that it generates the benchmark and then displays the result from that in one step. This should be separated so that you can generate different outputs without the need to re-run the time consuming benchmarks. If there is sufficient interest, I'll work on that. I've found that benchmarking different module versions automatically on a wide range of ops enablesme to discover bugs - if something is suddenly 2 times as slow than some subtle change broke something :) Best wishes, Tels -- Signed on Sun Aug 22 13:42:14 2004 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email. "Und jetzt kommen Sie!" - Stenkelfeld --Boundary-00=_4qIKBAMkjo+ZGFc Content-Type: application/x-perl; name="v0.01.inc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="v0.01.inc" #!/usr/bin/perl # bigbench template file. This runs the benchmark suite under the original # code. $| = 1; use lib '##path##/Math-BigInt-0.01/lib'; use Math::BigInt; use Math::BigFloat; use Benchmark; # output header and test for correct version my $need = 'Math::BigInt v0.01'; my $v = "Math::BigInt v$Math::BigInt::VERSION"; print "$v\n"; die "Can not load '$need', got '$v'\n" unless $v eq $need; $cf = 'Math::BigFloat::Bench'; $c = 'Math::BigInt::Bench'; ############################################################################### package Math::BigInt::Bench; use Exporter; @ISA = qw/Exporter Math::BigInt/; sub copy { Math::BigInt::Bench->new(shift); } ################################################################################ package Math::BigFloat::Bench; use Exporter; @ISA = qw/Exporter Math::BigFloat/; sub copy { Math::BigFloat::Bench->new(shift); } package main; my ($x,$y,$z); # actual benchmarking code will be appended --Boundary-00=_4qIKBAMkjo+ZGFc Content-Type: application/x-perl; name="v1.72.inc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="v1.72.inc" #!/usr/bin/perl -w # bigbench template file. $| = 1; use lib '##path##/Math-BigInt-1.72/lib'; use Math::BigInt; use Math::BigFloat; use Benchmark; my $c = 'Math::BigInt'; my $cf = 'Math::BigFloat'; # output header and test for correct version my $need = 'Math::BigInt v1.72 lib => Math::BigInt::Calc v0.42'; my $v = "Math::BigInt v$Math::BigInt::VERSION "; if (Math::BigInt->can('config')) { $v .= "lib => ". Math::BigInt->config()->{'lib'}; $v .= ' v' . Math::BigInt->config()->{'lib_version'}; } print "$v\n"; die "Cannot load '$need', got '$v'\n" unless $v eq $need; # actual benchmarking code will be appended --Boundary-00=_4qIKBAMkjo+ZGFc Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =2D----BEGIN PGP SIGNED MESSAGE----- Moin, this is something that I had a long time sitting on my harddisk. I uploaded= =20 v0.10 to http://bloodgate.com/perl/packages/BigBench-0.10.tar.gz This is a small script that makes benchmarking different module or even Per= l=20 versions against eachother much easier. BigBench v0.10 (c) Copyright by Tels 2001-2002. Have fun! Usage : ./bb [options] Options: --help print this screen and exit --accuracy=3Ddigits round results to so many digits --base=3Dnumber print relative summary based on number --code=3Dsourcecode bench code snippet and ignore definitions --definitons=3Dfile from where to read benchmark definitions --duration=3Dseconds run each op for at least this time --nosummary don't print summary --nointeger don't round results to integer --nounlink don't unlink temporary files (for debug) --path=3Dlibpath path to libraries used by templates --runs=3Dnumber run benchmark more than once (see --take) --simulate=3Dsr simulate results by using srand(sr) --skew=3Dfactor scale reported numbers by factor --take=3Drun take lowest|average|highest|last --templates=3Dpath path to templates to be used --terse terse summary (unless --nosummary) --tight more tight summary (smaller spacing) Options may be abbreviated, their case does not matter. Examples: ./bb --def=3Dmath.def --terse --skew=3D2.1 # better printa= ble? ./bb --def=3Dstr.def --inc=3Dmath --duration=3D5 # really=20 fine-grained ./bb --def=3Dsome.def --nosummary # detailed ./bb --def=3Dsome.def --terse --base=3D100 # simulate perl= bench ./bb --code=3D'"ababba" =3D~ /a+/;' # only this ./bb --runs=3D2 --take=3Dlast # cache, then b= ench Here is an excerpt from a definition file, specifiying four ops to=20 benchmark: group=3Dbcmp#0#Big integer bcmp 0#1 1#$x=3D$c->new('1');$y=3D$x->copy();##$x->bcmp($y); 0#1e10 1e10#$x=3D$c->new('1'x10);$y=3D$x->copy();##$x->bcmp($y); group=3Dbsqrt#0#Big integer square root 0#5#$x=3D$c->new('5');#$x->copy();#$x->copy()->bsqrt(); 0#12#$x=3D$c->new('12');#$x->copy();#$x->copy()->bsqrt(); The latter two benchmark the copy() seperately from the copy()->bsqrt() to= =20 determine how much the bsqrt() takes alone. The copy() is neccessary to=20 always bench the same bsqrt() operations (it would change $x otherwise). I also attached two template files that do the actual benchmarking. First=20 they make sure that the proper modules are loaded, then setup the opration= =20 (notable "$c" because our definition file will use this). Of course, you can also just benchmark any code snippet: ./bb --code=3D'$a =3D~ /abc/' The biggst TODO is currently that it generates the benchmark and then=20 displays the result from that in one step. This should be separated so that= =20 you can generate different outputs without the need to re-run the time=20 consuming benchmarks. If there is sufficient interest, I'll work on that. I've found that benchmarking different module versions automatically on a=20 wide range of ops enablesme to discover bugs - if something is suddenly 2=20 times as slow than some subtle change broke something :) Best wishes, Tels =2D --=20 Signed on Sun Aug 22 13:42:14 2004 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email. "Und jetzt kommen Sie!" - Stenkelfeld =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. iQEVAwUBQSiKaXcLPEOTuEwVAQFYRwf9EvMJF/SutulehdNTOk86vVBV9yqTYcRl Ap6qm4AGA3caPi5Y40oKxNxVleDFNp7esDL4ncc+KElVGVv0gZqG5PWZSccNwAHY pXRNOZhndUHbP6v3gwdXdIpUJCURjR3jnV+XwjYaSrZ2vPua4Lhklaj/PX3EIY7h jT1zr7vaN5fbniVBt4zFpq8bl58n0s2JSahLY92+VI+onU4MoRtsUKDy8gK67Rxs VRpaBgs4WAgoNewa664ydew5Qd4EANBHX2Tyj6MJ94EYges79I2ZJ+ivcw+nYARg hGW79D9DnmI2mYhaIcdWGXV+Pus6JnvKSdZlK4M52pzNFE9Tdqc8ig=3D=3D =3DOn8n =2D----END PGP SIGNATURE----- --Boundary-00=_4qIKBAMkjo+ZGFc Content-Type: application/x-perl; name="v0.01.inc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="v0.01.inc" #!/usr/bin/perl # bigbench template file. This runs the benchmark suite under the original # code. $| = 1; use lib '##path##/Math-BigInt-0.01/lib'; use Math::BigInt; use Math::BigFloat; use Benchmark; # output header and test for correct version my $need = 'Math::BigInt v0.01'; my $v = "Math::BigInt v$Math::BigInt::VERSION"; print "$v\n"; die "Can not load '$need', got '$v'\n" unless $v eq $need; $cf = 'Math::BigFloat::Bench'; $c = 'Math::BigInt::Bench'; ############################################################################### package Math::BigInt::Bench; use Exporter; @ISA = qw/Exporter Math::BigInt/; sub copy { Math::BigInt::Bench->new(shift); } ################################################################################ package Math::BigFloat::Bench; use Exporter; @ISA = qw/Exporter Math::BigFloat/; sub copy { Math::BigFloat::Bench->new(shift); } package main; my ($x,$y,$z); # actual benchmarking code will be appended --Boundary-00=_4qIKBAMkjo+ZGFc Content-Type: application/x-perl; name="v1.72.inc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="v1.72.inc" #!/usr/bin/perl -w # bigbench template file. $| = 1; use lib '##path##/Math-BigInt-1.72/lib'; use Math::BigInt; use Math::BigFloat; use Benchmark; my $c = 'Math::BigInt'; my $cf = 'Math::BigFloat'; # output header and test for correct version my $need = 'Math::BigInt v1.72 lib => Math::BigInt::Calc v0.42'; my $v = "Math::BigInt v$Math::BigInt::VERSION "; if (Math::BigInt->can('config')) { $v .= "lib => ". Math::BigInt->config()->{'lib'}; $v .= ' v' . Math::BigInt->config()->{'lib_version'}; } print "$v\n"; die "Cannot load '$need', got '$v'\n" unless $v eq $need; # actual benchmarking code will be appended --Boundary-00=_4qIKBAMkjo+ZGFc-- ----