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_8] Optimize comparison between string #264

Closed jingkaimori closed 8 months ago

jingkaimori commented 8 months ago

Optimize comparison of two string by dictionary order. After this work, performance of large string comparison is improved twice, however short one is not improved.

Performance

Before

ns/op op/s err% total benchmark
22.16 45,121,128.76 0.2% 0.01 compare string
145.29 6,882,788.16 1.5% 0.01 compare larger string

After

ns/op op/s err% total benchmark
23.05 43,390,782.34 4.6% 0.01 compare string
68.25 14,651,940.51 1.5% 0.01 compare larger string