Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Faster and more efficient way to read a file vertically

by karlgoethebier (Abbot)
on Nov 05, 2017 at 14:15 UTC ( [id://1202776]=note: print w/replies, xml ) Need Help??


in reply to Re: Faster and more efficient way to read a file vertically
in thread Faster and more efficient way to read a file vertically

"...It looks like the more efficient choice would be to use unpack..."

I'm not so sure. As you wrote:

$ perl test.pl Rate unpack substr split unpack 171232877/s -- -23% -31% substr 223713647/s 31% -- -10% split 248138958/s 45% 11% --

Ergo:

karls-mac-mini:monks karl$ perl -e 'printf ("%.1f\n", 248138958/171232 +877);' 1.4

As i wrote at Re^6: Question on Regex:

"...use cmpthese, the results are sorted from slow to fast..."

Sorry in advance if i did something wrong missed something.

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Replies are listed 'Best First'.
Re^3: Faster and more efficient way to read a file vertically
by thanos1983 (Parson) on Nov 06, 2017 at 09:43 UTC

    Hello karlgoethebier,

    You are absolutely right. I also read the Benchmark/Optional-Exports where is clearly stated:

    cmpthese ( COUNT, CODEHASHREF, [ STYLE ] ) Optionally calls timethese(), then outputs comparison chart. This: cmpthese( -1, { a => "++\$i", b => "\$i *= 2" } ) ; outputs a chart like: Rate b a b 2831802/s -- -61% a 7208959/s 155% --

    This chart is sorted from slowest to fastest, and shows the percent speed difference between each pair of tests. cmpthese can also be passed the data structure that timethese() returns:

    Thanks for correcting me I will also update my answer. Although to be honest I am kind of impressed how unpack is slower in comparison to substr and split.

    Thanks again for your time and effort, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

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

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

    No recent polls found