miloyip / itoa-benchmark Goto Github PK
View Code? Open in Web Editor NEWC++ integer-to-string conversion benchmark
License: MIT License
C++ integer-to-string conversion benchmark
License: MIT License
Hello
Please have a look at the Sourceforge project:
https://sourceforge.net/projects/itoa/files/itoa/
http://itoa.cvs.sourceforge.net/itoa/itoa/
It gives interesting performance compared to the existing benches.
On top of that:
Regards
Remi
Thanks for the inspiration, I think I have improved it a bit too (~30% speedup):
https://code.google.com/p/protobuf/source/browse/trunk/src/google/protobuf/stubs/strutil.cc#892
64-bit is also available.
Currently the time unit is millisecond per test.
It is not very intuitive as audiences need to know the test size.
I suggest to change it to nanosecond per operation. It is more intuitive and can be compared to other operation such as dtoa()
.
Line 272 in 1f2b870
This function depends on undefined behavior for std::numeric_limits<int32_t>::min():
void i32toa_sse2(int32_t value, char* buffer) {
if (value < 0) {
*buffer++ = '-';
value = -value;
}
u32toa_sse2(static_cast<uint32_t>(value), buffer);
}
value = -std::numeric_limits<int32_t>::min() is not defined in C++:
http://stackoverflow.com/questions/16188263/is-signed-integer-overflow-still-undefined-behavior-in-c
I've observed g++ 4.9.1 create code that segfaults: it incorrectly enters the if (v < 10000) branch then tries to lookup gDigitsLut[d1] because d1 is too big.
Recommend:
void i32toa_sse2(int32_t value, char* buffer) {
if (value < 0) {
*buffer++ = '-';
u32toa_sse2(~static_cast<uint32_t>(value) + 1, buffer);
} else {
u32toa_sse2(static_cast<uint32_t>(value), buffer);
}
}
Same for 64.
folly conversion has been added to source, need to update the benchmark ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.