How fast is an EVAL String

Scott Penrose scottp at dd.com.au
Mon Apr 26 18:41:05 CDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> That's a very unreliable way to run benchmarks, Scott. The results may 
> vary greatly if the system load varies during the execution. It 
> doesn't change the results much, but you better use Benchmark for 
> that:

Absolutely. I also ran via profile as well, which is fairly accurate. I 
did not use Benchmark on this one but should have.

One thing I have learnt after lots of performance tuning and 
optimisation is that benchmark and profiling only give you clues, and 
the only thing that matters is how fast the code runs on the actual 
boxes. See one change may cause more load on the system because it goes 
into swap etc. this should be included in the measurements. Of course 
using my own argument, even this test means nothing until I put it in 
place with all the other code and run a typical hours results through 
the system.

The problem with most benchmarking and profiling is learning where to 
work on. And unfortunately this can't be done because doing the 
profiling and benchmarking changes exactly that - the system you are 
watching changes. You will notice that my code included a lot of 
unnecessary code if all I wanted to do was compare "eval" with 
"iterative" - but it was more real world.

In place with the whole system I have profiled it again, and with the 
same data running through the system it performance about twice as fast 
with the iterative method.

Either way you are absolutely right that on testing this type of code 
Benchmark is an essential tool that should be used. Thanks heaps !

Scott

>
> package main;
>
> use strict;
> use warnings;
>
> use Benchmark;
>
> my $d = Dummy->new();
>
> timethese(1000,
>           {
>            data1 => sub { run("data1") },
>            data2 => sub { run("data2") },
>           });
>
>
> sub run {
>     my $m = shift;
>     foreach my $id (@$list) {
>         my $str = $d->$m($id);
>         die "Failed data" unless ($str||'' eq "string");
>     }
> }
>
> the methods data1 and data2 are also unfair, the second one sets:
>
>   local $SIG{__DIE__} = sub { die $_[0]; };
>
> while the first one does not.
>
> In any case, this doesn't significantly change the point that you were 
> trying to make :)
>
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas at stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com
>
>
>
- -- 
Scott Penrose
Anthropomorphic Personification Expert
http://search.cpan.org/search?author=SCOTT
scott at cpan.org

Dismaimer: While every attempt has been made to make sure that this 
email only contains zeros and ones, there has been no effort made to 
guarantee the quantity or the order.

Please do not send me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFAjZ4TDCFCcmAm26YRAkdvAJ972uEKTco3nVIhDOIDlkMzvkwMOwCglCDM
uvXYOVOG0BOJ2Rbb6o4g5/4=
=Ui/W
-----END PGP SIGNATURE-----




More information about the Melbourne-pm mailing list