In addition to several fixes and improved error detection and messages (thanks Alexey Kasantsev), the DWScript SVN version now includes string concatenation improvement for the common “s := s + …” case.
Just for illustration, the execution times for the following test snippet
for i:=1 to 5000000 do buf := buf + IntToStr(i);
are right now on my machine:
- Delphi: 670 ms
- C#: 910 ms (using StringBuilder)
- DWScript: 1430 ms
- C#: like… forever (using string concatenation)
and when appending constant strings
for i:=1 to 5000000 do buf := buf + 'abc';
the timings are:
- Delphi: 150 ms
- C#: 170 ms (using StringBuilder)
- DWScript: 220 ms
I didn’t include PascalScript, as its execution times were too long, in both cases.
Oddly enough, it’s now faster to concatenate using the “s:=s+…” or “s+=…” patterns than using TStringBuilder. This is in part thanks to FastMM, in part because of TStringBuilder, and in part because TStringBuilder does not yet benefit from a “fast path” in DWScript.
3 thoughts on “String concatenation redux”
wooohooo!! that’s super 😀
Since writing the above, and after looking at TStringBuilder performance, I’ve ditched most usages of TStringBuilder from DWS, replacing it with a new class, which so far seems to be from 2 to 3 times faster than TStringBuilder (and thus now faster than string concatenation). This affects primarily the HTML filter and the default result.
Still need to introduce a fast path for script-side TStringBuilder.
Looks way cool!
Cant wait til DWS is final. Mentioned you in my last post, the “wrap up” for 2010: http://delphimax.wordpress.com/2010/12/20/a-year-of-delphi-developer/
Comments are closed.