Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: (tye)Re: Benchmarking the basic operations

by coreolyn (Parson)
on Jan 30, 2001 at 20:23 UTC ( #55258=note: print w/ replies, xml ) Need Help??


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

You said,"

    Comparing the speed of lt, gt, ge, le, ne, and eq is just, well, silly. The difference comes down to a fraction of a machine language instruction. The time it takes to dispatch a single Perl opcode dwarfs that like a flea on an aircraft carrier. "

How do you define dispatch and opcode? Apparently I'm not even literate in what constructs to focus on when optimizing, or how to isolate dispatch in a benchmark.

coreolyn


Comment on Re: (tye)Re: Benchmarking the basic operations
(tye)Re2: Benchmarking the basic operations
by tye (Cardinal) on Jan 30, 2001 at 20:55 UTC

    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")

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://55258]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-08-22 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (146 votes), past polls