Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Benchmarking the basic operations

by Falkkin (Chaplain)
on Jan 24, 2001 at 22:16 UTC ( #54064=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Benchmark;
    
    sub p_add { for my $i (1..100) { for (1..100) { $_ + $i  } } }
    ...
                not => \&p_not, shl => \&p_shl, shr => \&p_shr, 
                gt  => \&p_gt,  gte => \&p_gte, lt  => \&p_lt,  
                lte => \&p_lte, eq  => \&p_eq,  ne  => \&p_ne });
    
  2. or download this
     lt: 2392 wallclock secs (2373.87 usr +  0.12 sys = 2373.99 CPU) @ 42.
    +12/s (n=100000)
    gte: 2392 wallclock secs (2374.10 usr +  0.18 sys = 2374.28 CPU) @ 42.
    +12/s (n=100000)
     eq: 2401 wallclock secs (2381.67 usr +  0.33 sys = 2382.00 CPU) @ 41.
    +98/s (n=100000)
     gt: 2405 wallclock secs (2387.47 usr +  0.10 sys = 2387.57 CPU) @ 41.
    +88/s (n=100000)
    lte: 2417 wallclock secs (2398.93 usr +  0.08 sys = 2399.01 CPU) @ 41.
    +68/s (n=100000)
     ne: 2470 wallclock secs (2411.78 usr +  1.70 sys = 2413.48 CPU) @ 41.
    +43/s (n=100000)
    
  3. or download this
    perl -MO=Deparse,-p -we 'print 1 if $foo >= $bar'
    (($foo >= $bar) and print(1));
    -e syntax OK
    
  4. or download this
    perl -MO=Deparse,-p -we 'print 1 if $foo < $bar'
    (($foo < $bar) and print(1));
    -e syntax OK
    
  5. or download this
    not: 2231 wallclock secs (2225.95 usr +  0.45 sys = 2226.40 CPU) @ 44.
    +92/s (n=100000)
    shr: 2653 wallclock secs (2478.63 usr +  3.47 sys = 2482.10 CPU) @ 40.
    +29/s (n=100000)
    and: 2513 wallclock secs (2493.72 usr +  0.31 sys = 2494.03 CPU) @ 40.
    +10/s (n=100000)
     or: 2549 wallclock secs (2534.75 usr +  0.39 sys = 2535.14 CPU) @ 39.
    +45/s (n=100000)
    shl: 2921 wallclock secs (2507.25 usr +  6.75 sys = 2514.00 CPU) @ 39.
    +78/s (n=100000)
    xor: 2797 wallclock secs (2560.60 usr +  2.05 sys = 2562.65 CPU) @ 39.
    +02/s (n=100000)
    
  6. or download this
    add: 2841 wallclock secs (2682.82 usr +  0.67 sys = 2683.49 CPU) @ 37.
    +26/s (n=100000)
    mul: 3048 wallclock secs (2696.55 usr +  2.84 sys = 2699.39 CPU) @ 37.
    +05/s (n=100000)
    sub: 2743 wallclock secs (2734.40 usr +  0.55 sys = 2734.95 CPU) @ 36.
    +56/s (n=100000)
    mod: 2878 wallclock secs (2755.51 usr +  0.88 sys = 2756.39 CPU) @ 36.
    +28/s (n=100000)
    div: 3018 wallclock secs (2989.89 usr +  0.65 sys = 2990.54 CPU) @ 33.
    +44/s (n=100000)
    pwr: 3883 wallclock secs (3549.47 usr +  5.42 sys = 3554.89 CPU) @ 28.
    +13/s (n=100000)
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2014-08-01 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls