Top 5
Sergey Gromov
snake.scaly at gmail.com
Sat Oct 11 09:52:30 PDT 2008
Sat, 11 Oct 2008 09:05:26 -0500,
Andrei Alexandrescu wrote:
> Sergey Gromov wrote:
> > Sat, 11 Oct 2008 12:16:43 +0200,
> > Sascha Katzner wrote:
> >> - The StringBuilder in the Java version is *much* faster because it
> >> doesn't have to allocate a new memory block in each step. You can use a
> >> similar class in D too, without the need of a special string class/object.
> >
> > I agree here. Both word tango.text.Util.split and runConcatenateTest
> > use default array appending which is currently dead slow. Benji, to
> > actually compare the speed of string operations you better use one of
> > array builders discussed in this group.
>
> If anyone wants to try it, I'm pasting the draft version of Appender
> from std.array below.
I took the trouble to port your Appender to DMD 1.033 and fixed Benji's
benchmark to use it. Here's my timings, best of 5 runs each:
D: 0.37s
Java: 1.05s
Here are sample logs from both:
> >StringTest2.exe
> time to load file: 0.008575 seconds
> iterated through 3921852 characters, and found 910473 spaces in 0.051324 seconds
> String.indexOf(): found 31318 instances of 'the' in 0.033293 seconds
> replaced 31318 instances of 'the' with 'XXXX' in 0.085224 seconds
> split text into 910474 words in 0.109966 seconds
> concatenated 910474 words (with 3921853 chars) in 0.085061 seconds
> overall test duration: 0.374258 seconds
> >java StringTest
> time to load file: 0.104578655 seconds
> iterated through 3921852 characters, and found 910473 spaces in 0.026583267 seconds
> String.indexOf(): found 31318 instances of 'the' in 0.014550173 seconds
> replaced 31318 instances of 'the' with 'XXXX' in 0.212482871 seconds
> split text into 910474 words in 0.452282064 seconds
> concatenated 910474 words (with 3921853 chars) in 0.220009526 seconds
> overall test duration: 1.054729581 seconds
Who rules? ;D
More information about the Digitalmars-d
mailing list