Conversion to string + string building benchmark

bearophile bearophileHUGS at lycos.com
Sat Mar 19 19:14:50 PDT 2011


Robert Jacques:

Happy to see my post was not fully lost in the noise :-)

> And I would  
> hazard that Java's StringBuilder isn't giving you O(1) access to the  
> underlying array like Appender is, which would allow it to drastically  
> reduce memory churn.

The first purpose of an Appender/builder is to build an array as fast as possible. I don't need a very access to the array while I build it (a Deque too allows O(1) too, just a bit slower).


> In the future, you should also include program ram usages in these kind of  
> benchmarks.

The amount of memory used/commited is less easy to measure precisely, here are approximated values, the result are weird:

Timings, best of 3, n = 10_000_000, MB (commit):
  D test1:  290
  D test2a: 186
  D test2b:   1.9
  D test3:  188
  D test4:  106
  Java -Xmx500M -server Test1:  355
  Java -Xmx500M -server Test2a: 355
  Java -Xmx500M -server Test2b: 355

Bye,
bearophile


More information about the Digitalmars-d mailing list