Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
One Benchmark:
use strict; use Benchmark; for ( 1..5 ) # Do five tests. { $_ = int( rand(10_000) ) ** int( rand(3) + 2 ); print $_, "\n"; timethese( 1_000_000, { 'KM' => sub { 1 while s/^(-?\d+)(\d{3})/$1,$2/ }, 'Merlyn' => sub { s/(\d)(?=(\d{3})+(\D|$))/$1\,/g } }); print "\n", "- " x 39, "-\n"; }
Results:
82755409
Benchmark: timing 1000000 iterations of KM, Merlyn...
        KM:  1 wallclock secs ( 1.04 usr +  0.00 sys =  1.04 CPU) @ 958772.77/s
(n=1000000)
    Merlyn:  1 wallclock secs ( 0.49 usr +  0.00 sys =  0.49 CPU) @ 2036659.88/s
 (n=1000000)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
293198635825936
Benchmark: timing 1000000 iterations of KM, Merlyn...
        KM:  1 wallclock secs ( 1.05 usr +  0.00 sys =  1.05 CPU) @ 949667.62/s
(n=1000000)
    Merlyn:  0 wallclock secs ( 0.49 usr +  0.00 sys =  0.49 CPU) @ 2036659.88/s
 (n=1000000)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
602425897921
Benchmark: timing 1000000 iterations of KM, Merlyn...
        KM:  0 wallclock secs ( 1.05 usr +  0.00 sys =  1.05 CPU) @ 949667.62/s
(n=1000000)
    Merlyn:  0 wallclock secs ( 0.47 usr +  0.00 sys =  0.47 CPU) @ 2123142.25/s
 (n=1000000)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1.80935247108226e+015
Benchmark: timing 1000000 iterations of KM, Merlyn...
        KM:  1 wallclock secs ( 1.04 usr +  0.00 sys =  1.04 CPU) @ 958772.77/s
(n=1000000)
    Merlyn:  1 wallclock secs ( 0.46 usr +  0.00 sys =  0.46 CPU) @ 2169197.40/s
 (n=1000000)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106294343553
Benchmark: timing 1000000 iterations of KM, Merlyn...
        KM:  1 wallclock secs ( 1.04 usr +  0.00 sys =  1.04 CPU) @ 958772.77/s
(n=1000000)
    Merlyn:  1 wallclock secs ( 0.48 usr +  0.00 sys =  0.48 CPU) @ 2083333.33/s
 (n=1000000)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

In reply to RE: regexp for adding commas to a number by Adam
in thread regexp for adding commas to a number by Kozz

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 sharing their wisdom with the Monastery: (7)
As of 2024-03-28 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found