in reply to Re: Re: Tribute to TMTOWTDI
in thread Tribute to TMTOWTDI
The eval of the code snippets occurs within Benchmark,
Actually, this isn't correct. Benchmark goes through some interesting (not necessarily completely correct either)contortions to execute code from the package it was called from, in this case main.
This can be seen from this snippet from Benchmark::runloop which is the primary timing routine in Benchmark. (BTW, i only know this cause ive been working on a OO version of Benchmark, coming Real Soon Now to the Code Catacombs :-)
Oh and a note to andreychek I dont think that including print,warn statements in a benchmark (unless warn() is what you are benchmarking) is a good idea. The overhead of them executing probably drowns out the difference between the functions. Yves / DeMerphq# find package of caller so we can execute code there my($curpack) = caller(0); my($i, $pack)= 0; while (($pack) = caller(++$i)) { last if $pack ne $curpack; } my ($subcode, $subref); if (ref $c eq 'CODE') { $subcode = "sub { for (1 .. $n) { local \$_; package $pack; &\$c; +} }"; $subref = eval $subcode; } else { $subcode = "sub { for (1 .. $n) { local \$_; package $pack; $c;} } +"; $subref = _doeval($subcode); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Tribute to TMTOWTDI
by chipmunk (Parson) on Oct 26, 2001 at 17:51 UTC | |
by demerphq (Chancellor) on Oct 26, 2001 at 18:24 UTC |