Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: syntax question (some Bench)

by Discipulus (Canon)
on Oct 24, 2013 at 07:25 UTC ( [id://1059398]=note: print w/replies, xml ) Need Help??


in reply to syntax question

Consider also that regex are so optimezed so that the second option, using substr, 'may' become a 'little' faster then regexes only when you operate against huge data in a foreach loop:
#10 fields in the array iterating over: Benchmark: running Regex, Substr for at least 4 CPU seconds... Regex: 4.58121 wallclock secs ( 4.18 usr + 0.02 sys = 4.20 CPU) + @ 3968640.46/s (n=16656384) Substr: 4.38291 wallclock secs ( 4.32 usr + 0.00 sys = 4.32 CPU) + @ 3927240.92/s (n=16969608) #100 fields Benchmark: running Regex, Substr for at least 4 CPU seconds... Regex: 4.56133 wallclock secs ( 4.12 usr + -0.01 sys = 4.11 CPU) + @ 3995786.36/s (n=16402703) Substr: 4.29298 wallclock secs ( 4.03 usr + 0.00 sys = 4.03 CPU) + @ 4190639.34/s (n=16871514) #1000 fields ###Regex is faster!! (tested 5 times) Benchmark: running Regex, Substr for at least 4 CPU seconds... Regex: 4.1849 wallclock secs ( 4.03 usr + 0.01 sys = 4.04 CPU) +@ 4139558.42/s (n=16723816) Substr: 5.5707 wallclock secs ( 4.26 usr + 0.00 sys = 4.26 CPU) +@ 3843370.27/s (n=16368914) #10000 fields Benchmark: running Regex, Substr for at least 4 CPU seconds... Regex: 4.87697 wallclock secs ( 4.68 usr + 0.00 sys = 4.68 CPU) + @ 3600221.37/s (n=16849036) Substr: 4.21117 wallclock secs ( 3.99 usr + 0.03 sys = 4.02 CPU) + @ 4352730.93/s (n=17519742) #BUT ALSO 10000 fields Benchmark: running Regex, Substr for at least 4 CPU seconds... Regex: 4.32358 wallclock secs ( 4.09 usr + -0.02 sys = 4.07 CPU) + @ 3946014.74/s (n=16064226) Substr: 4.44415 wallclock secs ( 4.10 usr + 0.03 sys = 4.13 CPU) + @ 3892862.84/s (n=16093095)
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found