Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Perl regex speed

by malaigo (Novice)
on Oct 25, 2022 at 07:35 UTC ( [id://11147672]=perlquestion: print w/replies, xml ) Need Help??

malaigo has asked for the wisdom of the Perl Monks concerning the following question:

I have Perl on a Apple M1 Max Mac laptop (2021) and a Core i9 Mac laptop (2018). I assumed Perl compiled for arm64 would run much faster than Perl for x86_64.

With regex, it doesn't seem to be the case. The one-liner I used was time perl -e '$n = shift; $na = "a" x $n; print $na =~ /(a?){$n}a{$n}/' X where X ranges over 5,10,15,20,24,30 etc.

Results graphed at sandiway.arizona.edu/temp/538/perl%20comparison.png

EDIT: direct link

Replies are listed 'Best First'.
Re: Perl regex speed
by jwkrahn (Abbot) on Oct 25, 2022 at 08:08 UTC

    You have a seriously bad regular expression. I don't see how it could be improved by running on a different architecture.

    Try running it like this:

    perl -Mre=debug -le'$n = shift; $na = "a" x $n; print $na =~ /(a?){$n} +a{$n}/'
      You don't understand. This is for teaching. It's supposed to be a worst case scenario for backtracking regex implementations. The question is how come the arm64 version doesn't blow away the x86 one.
Re: Perl regex speed
by cavac (Prior) on Oct 25, 2022 at 08:01 UTC
      Yes, %20. And generally, you are correct. I don't mind linking, but it wouldn't let me link in the original query for some reason.

        Did you just copy&paste the link from somewhere? PM doesn't do any encoding for you, it just uses your text to generate HTML. Depending on the source of your link, you might have to do the encoding step manually (or run it through a browser url input once). And you have to add the link HTML tags yourself, PM doesn't do that for you.

        Text only: https://example.com/Hello World https://example.com/Hello%20World Wrong encoding: <a href="https://example.com/Hello World">Examle link</a> Correct encoding: <a href="https://example.com/Hello%20World">Example link</a>

        PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Re: Perl regex speed
by dave_the_m (Monsignor) on Oct 25, 2022 at 17:51 UTC
    so, what's your question?
      The question is, why isn't the latest Apple Silicon implementation faster than the Intel one on Perl regex?(Assuming it is arm64 and not emulated x86_64.)
        Why would you expect arm64 to be noticeably faster? Have ARM patented some amazing new technology that Intel can't use?

        Dave.

        A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11147672]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2025-12-16 15:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (96 votes). Check out past polls.

    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.