Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^6: Should multiplication by integer be avoided in favour of division for performance reasons? (benchmark pitfalls)

by dave_the_m (Monsignor)
on Nov 29, 2019 at 19:32 UTC ( #11109446=note: print w/replies, xml ) Need Help??


in reply to Re^5: Should multiplication by integer be avoided in favour of division for performance reasons? (benchmark pitfalls)
in thread Should multiplication by integer be avoided in favour of division for performance reasons?

Bear in mind that Benchmark.pm does something like the equivalent of
eval q[ for my $i (1..$n) { my @c = map $_ * 4, @a; } ]
Since the same multiply op is used for all iterations, once it gets "poisoned" by trying to return an IV value for the last element of the first iteration, further calls to that op will start returning PVNVs. So for iterations 2+, all elements of @c will be PVNVs and thus slower to free.

It's also the case that multiply is fractionally slower at returning a PVNV value rather than an NV value.

Dave.

  • Comment on Re^6: Should multiplication by integer be avoided in favour of division for performance reasons? (benchmark pitfalls)
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2020-10-26 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (250 votes). Check out past polls.

    Notices?