XmacsLabs / lolly

lolly: A user-friendly C++ library
https://xmacslabs.github.io/lolly/
GNU General Public License v3.0
10 stars 6 forks source link

[8_12] improve strategy of expanding string for performance #331

Closed jingkaimori closed 4 months ago

jingkaimori commented 4 months ago

see also #305

Performance

operator<< faster 2-3x than before

Before

ns/op op/s err% total benchmark
35.13 28,463,649.27 3.9% 0.22 construct string
2.66 376,488,992.00 1.7% 0.24 equality of string
17.68 56,561,986.49 1.0% 0.23 equality of larger string
4.14 241,610,858.14 0.9% 0.24 compare string
8.09 123,542,843.98 2.1% 0.24 compare larger string
18.23 54,847,647.47 0.6% 0.24 slice string
24.93 40,119,524.68 2.0% 0.24 slice string with larger range
31.80 31,447,902.44 0.9% 0.24 concat string
16.71 59,850,717.22 2.5% 0.24 append string
3.17 315,195,579.00 0.5% 0.24 is quoted

After

ns/op op/s err% total benchmark
33.35 29,984,690.73 2.4% 0.23 construct string
2.64 378,639,521.02 2.0% 0.24 equality of string
15.69 63,733,330.98 3.0% 0.23 equality of larger string
4.22 236,987,827.04 3.2% 0.25 compare string
8.50 117,694,065.06 3.1% 0.24 compare larger string
22.21 45,014,771.61 3.7% 0.23 slice string
25.88 38,644,124.66 0.3% 0.24 slice string with larger range
30.28 33,028,549.24 0.9% 0.24 concat string
6.81 146,814,049.22 3.7% 0.23 append string
3.20 312,586,648.76 0.7% 0.23 is quoted