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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I really encourage you to Benchmark instead of assuming. You will get surprises somewhat often. And assuming a simple arithmetic op is a performance killer seems silly. It took 10 million iterations to even be able to get this to benchmark without complaining it wasn't enough to be sure; and while a fifteenth of a millionth of a second is indeed three times faster than a fifth of a millionth of a second… does it actually matter on any level for the application in question?

moo@cow[483]~>perl pm-dice use strictures; use Benchmark "cmpthese"; sub d10 { my $self = shift; return rand(10); } sub d10_2 { rand(10) } sub d10_3 { 1 + int( rand(10) ) } sub d10_4 { 1 + rand(10) } cmpthese( 10_000_000, { orig => \&d10, orig_simple => \&d10_2, int_plus_one => \&d10_3, plus_one => \&d10_4, }); __END__ Rate orig int_plus_one plus_one orig_si +mple orig 4048583/s -- -19% -38% + -74% int_plus_one 5000000/s 24% -- -24% + -68% plus_one 6578947/s 62% 32% -- + -59% orig_simple 15873016/s 292% 217% 141% + --

In reply to Re^3: A small Deity AI class system by Your Mother
in thread A small Deity AI class system by holyghost

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-24 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found