On Saturday, 2 March 2013 at 00:47:02 UTC, Steven Schveighoffer
wrote:
On Fri, 01 Mar 2013 19:19:35 -0500, cvk012c
<[email protected]> wrote:
On Friday, 1 March 2013 at 21:52:13 UTC, bearophile wrote:
cvk012c:
I think that similar Perl and Java scripts will outperform D
easily.
Thanks Andrei and simendsjo for a quick response though.
Why don't you write a Java version? It takes only few
minutes, and you will have one more data point.
You are right. Why not. But instead of using Java split()
method I used combination of indexOf() and substring() methods
to do the same job. The reason: Java split method implemented
as a regular expression which will be unfair to compare to D
splitter. Again, I created a similar D version of the script,
compiled it with all suggested options: -release -O -inline
-noboundscheck and this time D version is more then twice
slower than Java: 8.4 seconds vs 4.
D experts, please, take a look at my code and tell me what is
wrong with it.
The issue is a combination of the fact that:
1. splitter is designed for any range, not just strings. Not
an excuse really, but a string-specific version could be
written that does better (clearly).
In my latest version of D script I didn't use splitter at all. I
used string specific indexOf function. Still result is very bad.
For text based protocols, such as SIP, performance of string
manipulating functions is very important. Unfortunately, looks
like it is not D strongest point at this time.