Lexer in D

Namespace rswhite4 at googlemail.com
Mon Mar 11 08:11:42 PDT 2013


------------------------
Total time (ms): 10941.9
Repetitions    : 200
Sample mode    : 54 (118 ocurrences)
Median time    : 54.5855
Avg time       : 54.7094
Std dev.       : 1.33935
Minimum        : 52.535
Maximum        : 67.206
95% conf.int.  : [52.0843, 57.3345]  e = 2.62509
99% conf.int.  : [51.2594, 58.1593]  e = 3.44995
EstimatedAvg95%: [54.5238, 54.895]  e = 0.185622
EstimatedAvg99%: [54.4654, 54.9533]  e = 0.243948

And even a bit closer.

I've also done some benchmarks. And I wonder why my appender is 
much faster if I enable memory reservation.
My Appender: http://dpaste.1azy.net/1bb34d9a
I'm also very interested to hear some improvements tips.

In each benchmark 1_000_000 times these struct is appended:

struct B {
public:
	const int b;
}

Without memory reserve:

My Appender:
------------------------
Total time (ms): 7638.67
Repetitions    : 200
Sample mode    : 38 (68 ocurrences)
Median time    : 38.0545
Avg time       : 38.1934
Std dev.       : 1.56827
Minimum        : 35.859
Maximum        : 47.586
95% conf.int.  : [35.1196, 41.2671]  e = 3.07375
99% conf.int.  : [34.1538, 42.233]  e = 4.0396
EstimatedAvg95%: [37.976, 38.4107]  e = 0.217347
EstimatedAvg99%: [37.9077, 38.479]  e = 0.285643

D's Appender:
------------------------
Total time (ms): 6972.66
Repetitions    : 200
Sample mode    : 34 (97 ocurrences)
Median time    : 34.7795
Avg time       : 34.8633
Std dev.       : 1.41623
Minimum        : 32.96
Maximum        : 49.579
95% conf.int.  : [32.0876, 37.6391]  e = 2.77576
99% conf.int.  : [31.2153, 38.5113]  e = 3.64797
EstimatedAvg95%: [34.667, 35.0596]  e = 0.196276
EstimatedAvg99%: [34.6054, 35.1213]  e = 0.257951

D array:
------------------------
Total time (ms): 22868.2
Repetitions    : 200
Sample mode    : 110 (198 ocurrences)
Median time    : 113.658
Avg time       : 114.341
Std dev.       : 1.97184
Minimum        : 113.011
Maximum        : 133.978
95% conf.int.  : [110.477, 118.206]  e = 3.86473
99% conf.int.  : [109.262, 119.42]  e = 5.07911
EstimatedAvg95%: [114.068, 114.615]  e = 0.273277
EstimatedAvg99%: [113.982, 114.7]  e = 0.359147

With memory reserve:

My Appender:
------------------------
Total time (ms): 6197.48
Repetitions    : 200
Sample mode    : 30 (88 ocurrences)
Median time    : 30.617
Avg time       : 30.9874
Std dev.       : 2.86913
Minimum        : 28.583
Maximum        : 64.06
95% conf.int.  : [25.364, 36.6108]  e = 5.62339
99% conf.int.  : [23.597, 38.3778]  e = 7.39039
EstimatedAvg95%: [30.5897, 31.385]  e = 0.397634
EstimatedAvg99%: [30.4648, 31.51]  e = 0.52258

D's Appender:
------------------------
Total time (ms): 6628.31
Repetitions    : 200
Sample mode    : 32 (104 ocurrences)
Median time    : 32.6775
Avg time       : 33.1415
Std dev.       : 3.00344
Minimum        : 31.506
Maximum        : 57.493
95% conf.int.  : [27.2549, 39.0282]  e = 5.88663
99% conf.int.  : [25.4052, 40.8779]  e = 7.73635
EstimatedAvg95%: [32.7253, 33.5578]  e = 0.416248
EstimatedAvg99%: [32.5945, 33.6886]  e = 0.547042

D array:
------------------------
Total time (ms): 22849.9
Repetitions    : 200
Sample mode    : 110 (198 ocurrences)
Median time    : 113.025
Avg time       : 114.249
Std dev.       : 8.40906
Minimum        : 112.355
Maximum        : 222.982
95% conf.int.  : [97.768, 130.731]  e = 16.4815
99% conf.int.  : [92.5891, 135.91]  e = 21.6603
EstimatedAvg95%: [113.084, 115.415]  e = 1.16542
EstimatedAvg99%: [112.718, 115.781]  e = 1.53162


More information about the Digitalmars-d-learn mailing list