Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Everytime I've looked at that regex ive thought the same thing: what a strange regex to use for a comparison benchmark.

One optimisation that is missing from pre 5.9 Perl is that there is nothing to convert /x|y|z/ into the far more efficient /[xyz]/.* If javas regex engine does contain a compile time optimisation of this sort its almost guaranteed to run faster than released version of Perl. On 5.9 and later it would be handled somewhat better as a TRIE which would be much faster than before, but still not as efficient as if it had been a char class. (Any C programmers out there interested in a neat hack, converting TRIE regops with only one row in their table to proper char class nodes would be cool).

This factor coupled with the fact that he doesnt actually show what strings he matched against make me somewhat dubious of the value of his assertions.

Without looking at the optimisations built into the Java regex engine (which no doubt they do not release) its hard to say why Perl would be slower than Java. I personally wouldnt necessarily assume that it was the backtracking logic that was at fault without a better understanding of the test cases that he used for his timings.

* Update: IOW its probably not fair to penalize a system for performing one task inefficiently when there is an equivelent construct that is efficient, unless in the context of an overall comparison.

---
$world=~s/war/peace/g


In reply to Re: Benchmarks aren't everything by demerphq
in thread Benchmarks aren't everything by tilly

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 having a coffee break in the Monastery: (7)
As of 2024-03-29 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found