Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Fundamental Benchmarks

by kal (Hermit)
on Apr 02, 2001 at 12:58 UTC ( #68957=note: print w/replies, xml ) Need Help??

in reply to Fundamental Benchmarks

Without wanting to mention the usual 'benchmark', 'salt', 'pinch of', etc., it's worth noting that you seem to be aiming for implementation optimization rather than algorithmic optimization (although perhaps you have done the algorithmic, and are just currently interested in the implementation).

To be honest, I'm not sure I'd bother - your 'optimizations' are dependent on how a particular perl implements a feature, which isn't necessarily going to be consistent across versions of perl, and what might be fast now might be slow in the future.

As an example, take all those assembly (spit) programmers, who for years have shaved the time off a multiply instruction by barrel-shifting powers of two. Along comes the P4, with no barrel shift, and suddenly their 'optimization' damages performance like you would not believe.

I know it's not a fantastic answer, but don't bother with implementation optimization - read Knuth, improve your algorithms, and attain bliss :)

Replies are listed 'Best First'.
Re: Re: Fundamental Benchmarks
by Lexicon (Chaplain) on Apr 02, 2001 at 13:24 UTC
    To be sure, I've done quite a bit of work on Algorithmic optimization. What was some O(n!) time at first is now O(1) or O(n) (depending on use). But certain implimentation details lead me to need to choose between a Subroutine call vs a 2D-array lookup. I hadn't realized the Array would be so fast, even with 1 million cells. Subroutine calls are far more expensive than I expected. The array implimentation will probably increase the speed of the algorithm by 2-4 times, which makes me very satisfied that I went ahead and checked.

    For my purposes, I'm fairly confident, as I imagine that a subroutine will always be a few order of magnitude slower than an Array. All this assuming that my results have any lasting meaning at all, of course. ;)

    If people would dedicate a few minutes to look at this on different systems, that would be quite sweet. This particular benchmark ran under Redhat in Perl 5.00503. The box is (I think) a K6-2 250 with 256MB Ram, but I could be wrong on that processor. I'll post an ActiveState 5.6.0 under NT tomorrow if I get a chance.


      This is on an 270 MHz IP-27 (alternatively R12000--I'm not sure which label means more), using Perl 5.004_04.
      A = 10 B = 1000000 Benchmark: timing 10 iterations of 1 Nothing , 2 Mult , 3 Array + , 4 Hash , 5 Sub (Ref), 6 Sub (Val)... 1 Nothing : 30 secs (28.53 usr 0.03 sys = 28.56 cpu) 2 Mult : 63 secs (49.93 usr 0.07 sys = 50.00 cpu) 3 Array : 42 secs (37.05 usr 0.04 sys = 37.09 cpu) 4 Hash : 99 secs (95.28 usr 0.09 sys = 95.37 cpu) 5 Sub (Ref): 127 secs (117.77 usr 0.09 sys = 117.86 cpu) 6 Sub (Val): 98 secs (93.28 usr 0.11 sys = 93.39 cpu)
      Edit: fixed careless markup (sorry)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://68957]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-06-23 23:14 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.