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

Re^4: RE on lines read from in-memory scalar is very slow

by Anonymous Monk
on Jan 23, 2024 at 07:40 UTC ( [id://11157181]=note: print w/replies, xml ) Need Help??


in reply to Re^3: RE on lines read from in-memory scalar is very slow
in thread RE on lines read from in-memory scalar is very slow

FWIW, Win10 & Strawberry:

v5.32.1 tempfile.txt is size 29 Mb 0.115239 read lines from disk and do RE (32571 matches). 0.676642 read lines from in-memory file and do RE (32571 matches). v5.38.0 tempfile.txt is size 29 Mb 0.156708 read lines from disk and do RE (32571 matches). 0.628221 read lines from in-memory file and do RE (32571 matches). v5.26.3 tempfile.txt is size 29 Mb 0.122374 read lines from disk and do RE (32571 matches). 0.671405 read lines from in-memory file and do RE (32571 matches). v5.16.3 tempfile.txt is size 28 Mb 0.119628 read lines from disk and do RE (32760 matches). 0.057724 read lines from in-memory file and do RE (32760 matches).

Replies are listed 'Best First'.
Re^5: RE on lines read from in-memory scalar is very slow
by Anonymous Monk on Jan 24, 2024 at 08:44 UTC

    Couple other additions to assortment of facts:

    • if loops are changed to

      while(my $s = <$fh>) { $s =~ /^ ?Query/ && $match_count1++; }

      then deterioration gets significantly worse (compare to parent node):

      v5.32.1 tempfile.txt is size 29 Mb 0.121957 read lines from disk and do RE (32571 matches). 9.511288 read lines from in-memory file and do RE (32571 matches).
    • if loops are changed to

      while(my $s = <$fh>) { index( $s, 'Query' ) != -1 && $match_count1++;; }

      (the same without the "$s") then using in-memory string is (of course) faster:

      v5.32.1 tempfile.txt is size 29 Mb 0.092390 read lines from disk and do RE (32571 matches). 0.051797 read lines from in-memory file and do RE (32571 matches).
      if loops

      if is no loop.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        Read as "if the loops are changed to XYZ then ...". HTH.


        🦛

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2026-04-10 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.