in reply to Benchmarking the block and list forms of grep

You may want to see Wasting time thinking about wasted time. You really have to think about the numbers that Benchmark gives back to you, and running something four million times a second probably means you aren't actually running anything interesting. The benchmark I presented had the same problem you run into: void context optimization.

Update: After playing with this for a bit (I'm writing the Benchmarking Perl talk I'm giving tonight), I think you're benchmark isn't doing anything at all. Your code doesn't see your arrays. When I change the number of elements in the lists, the numbers don't change. When I change the arrays to package variables, things make much more sense. There still isn't a big difference between the methods though, but at least you aren't running a no-op 4 million times a second. :)

Another update: I featured this node in my UniForum talk tonight: Benchmarking Perl.

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review
  • Comment on Re: Benchmarking the block and list forms of grep