renard wrote:
BE AWARE THAT THE BENCHMARK PROVIDES INCORRECT RESULTS.
Thnaks, I was aware of that, but still wanted a general idea :)
The tested code is within an anonymous subroutine while this does executes, the results differ dramitcally from the results when the tested code is enclosed within single quotation marks.!!!
I do not know why the great difference ... perhaps the experts might be able to explain the difference. This is not the first time that I observe this divergence.
The test results below show when the tested code is enclosed within single quotation marks, the 'exists' code has a 40% advantage.
over the 'grep_e' code but has a 1100% advantage over the grep_e code when enclosed within an anonymous subroutine. The code enclosed inside the anonympous subroutine takes substantially longer to execute.
I tend to believe that the results for the single quotation mark is more accurate.
I'll use that info in the future, thanks!
So buyer beware ...
[snip]
Benchmark: timing 1000000 iterations of exists, grep_e, grep_r, hash...
exists: 2.99903 wallclock secs ( 2.97 usr + 0.01 sys = 2.98 CPU) @ 335232.99/s (n=1000000)
grep_e: 4.14286 wallclock secs ( 4.16 usr + 0.00 sys = 4.16 CPU) @ 240615.98/s (n=1000000)
grep_r: 3.93865 wallclock secs ( 3.92 usr + 0.00 sys = 3.92 CPU) @ 254971.95/s (n=1000000)
hash: 3.01261 wallclock secs ( 3.00 usr + 0.00 sys = 3.00 CPU) @ 333333.33/s (n=1000000)
Rate grep_e grep_r hash exists grep_e 240616/s -- -6% -28% -28% grep_r 254972/s 6% -- -24% -24% hash 333333/s 39% 31% -- -1% exists 335233/s 39% 31% 1% --
Benchmark: timing 1000000 iterations of exists, grep_e, grep_r, hash...
exists: 7.63617 wallclock secs ( 7.56 usr + 0.00 sys = 7.56 CPU) @ 132222.66/s (n=1000000)
grep_e: 14.9662 wallclock secs (14.72 usr + 0.00 sys = 14.72 CPU) @ 67939.40/s (n=1000000)
grep_r: 95.0288 wallclock secs (93.33 usr + 0.03 sys = 93.36 CPU) @ 10711.34/s (n=1000000)
hash: 15.6237 wallclock secs (15.50 usr + 0.02 sys = 15.52 CPU) @ 64449.60/s (n=1000000)
Rate grep_r hash grep_e exists grep_r 10711/s -- -83% -84% -92% hash 64450/s 502% -- -5% -51% grep_e 67939/s 534% 5% -- -49% exists 132223/s 1134% 105% 95% --
Excellent! I beleive from all the different tests I will be going with exists *and* more craefull how/what I benchmark :)
Thanks for your time!
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>