http://www.perlmonks.org?node_id=55264


in reply to Re: (tye)Re: Benchmarking the basic operations
in thread Benchmarking the basic operations

Sorry, those aren't my terms. :) Dispatching opcodes is a description I've heard of how Perl executes the code that it has compiled. So Perl has a fairly high overhead per opcode.

The constructs to focus on when optimizing are the contructs that take the big chunk of the time. And usually the only big win you have when optimizing is to change the algorithm, that is, change the whole way you do things. Tweaking tiny things here and there is usually a waste of your time.

Now occasionally you can do something simple like change a s/\W+//g to tr/a-zA-Z0-9_//cd and get a big speed improvement IF you are doing that operation on a huge number of really long strings.

Another way to look at is, if you need to use Benchmark.pm in order figure out which of two ways is faster, then it probably isn't worth your time to be worrying about that "optimization". Using Benchmark.pm is a good way to figure out how much faster something is. And it can be fun and/or interesting to compare things with Benchmark.pm. But if you don't have a real problem that runs noticeably faster after your change, then the change really didn't make much difference.

        - tye (but my friends call me "Tye")
  • Comment on (tye)Re2: Benchmarking the basic operations