Good point! I just wanted to compare equivalent substitutions.
Adding testC:
'testC' => sub { my $f = $test; $f =~ s/\s+,/,/g; $f =~ s/,\s+/,/g;
+},
100_000:
Rate test1 test2 test3 testA testC testB
test1 6.5/s -- -28% -66% -76% -80% -81%
test2 9.0/s 39% -- -53% -67% -73% -73%
test3 19.1/s 196% 113% -- -29% -42% -43%
testA 27.0/s 318% 201% 41% -- -18% -19%
testC 33.1/s 412% 269% 73% 23% -- -1%
testB 33.3/s 416% 272% 74% 23% 1% --
C is 23% faster than A, even running twice over some of the commas in the test string. B doesn't touch a comma twice, but is only 1% faster than C.
-
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.
|