My goal is to find the fastest C++ library for casting int to string, vice versa, and parsing.
Anyone that has experimented with performance of C++ will quickly realize that the string class of STL has terrible performance compared to say STL int arithmetic operations.
Some sample benchmarks from my 3.3 GHz Intel, GCC, CentOS 5.5 machine:
memcpy 0.004000 microsec/op
atoi 0.025000 microsec/op
atof 0.133000 microsec/op
strtod 0.133000 microsec/op
atof 0.135108 microsec/op
(char) uchar 0.001801 microsec/op
(char) ushort 0.001801 microsec/op
cache accs 0.010505 microsec/op
maplookup 0.128534 microsec/op
add_int 0.002456 microsec/op
You can quickly see that string operations will become a bottleneck for any high speed messaging applications.
I have located other libs for high performance strings (listed), but I am writing hoping someone has had similar difficulty and has reached some solution, possibly including writing their own string class.
You didn't provide much information about your servers, but have a look at these libraries from AMD and Intel:
AMD String Library
Intel Integrated Performance Primitives
Both use SSE extensions to speed up string operations.
As far as I can see, they have no atoi(), but you could use the libraries to locate the decimals in the input. Given the string location and length it should be trivial to write a conversion using SSE intrinsics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With