Next | Making Programs Faster | 114 |
What went wrong here?
The actual code was something like this:
my @filenames = glob("/tmp/*");
timethese(10**7, { 'CODE A' => '@sorted = sort { -M $b <=> -M $a } @filenames;', ... );
When you give strings to Benchmark, it executes them with eval
It does the eval internally, inside of Benchmark.pm
This is outside the scope of my @filenames
The benchmark is using @Benchmark::filenames, which is empty
You can indeed sort an empty list in 3.7 microseconds
But the results were entirely meaningless
Next | Copyright © 2003 M. J. Dominus |