Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Okay, I re-ran the benchmark with your exact code on my computer, and I got:
Benchmark: timing 1000000 iterations of index, s///, substr... index: 15 wallclock secs (14.02 usr + 0.00 sys = 14.02 CPU) @ 71 +326.68/s (n=1000000) s///: 13 wallclock secs (12.33 usr + 0.00 sys = 12.33 CPU) @ 81 +103.00/s (n=1000000) substr: 14 wallclock secs (13.37 usr + 0.00 sys = 13.37 CPU) @ 74 +794.32/s (n=1000000) Rate index substr s/// index 71327/s -- -5% -12% substr 74794/s 5% -- -8% s/// 81103/s 14% 8% --
So I guess it must be highly platform-dependent then. I'm using perl 5.8.0 on Mac OS X (darwin 6.3) on a PPC G3 (iBook).

Assuming you're using x86, a possible explanation would be that doing regex might benefit from the PPC's rich number of general-purpose registers, while the x86's memory-oriented instruction set is perhaps more suited at executing the (stack-based) perl opcodes.

But it's just a guess...

•Update: I'm enclosing all my benchmark stuff in readmore-tags to avoid cluttering the thread


In reply to Re: Re: Re: Re: Regex matching on anywhere but the beginning or end of a line by xmath
in thread Regex matching on anywhere but the beginning or end of a line by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-20 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found