An Interest In:
Web News this Week
- April 3, 2024
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
April 1, 2022 01:14 pm GMT
Original Link: https://dev.to/xeerx/i-created-a-string-system-faster-than-the-stdstring-4eli
I created a string system faster than the std::string!
Am I reinventing the wheel?
I deal with data for billions of times repeatedly, so it was necessary to reduce the time and resources consumed in those transactions, and for this I programmed this simple system, which in turn saved a lot of time and resources unlike other systems.
In the end, I tell you that this system is 5 times faster than the std::string system, and provides all the features that this system provides, so this system is definitely the best at all.
I'm not the type to talk a lot but wanted to share what I accomplished with you guys.
Performance test script compared to the std::string:
#include "xstr.h"#include <string>#include <chrono>int main(){std::cout << "x::xstr";std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();for(int i = 0; i < 100000; i++) { xstr x = "Hello World"; x += " Extra String"; }std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::cout << "
\033[1;30mExecute Time: " << std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count() / 1000 << "s \033[0m
"; std::cout << "std::string";std::chrono::steady_clock::time_point begin2 = std::chrono::steady_clock::now();for(int i = 0; i < 100000; i++) { std::string x = "Hello World"; x += " Extra String"; }std::chrono::steady_clock::time_point end2 = std::chrono::steady_clock::now(); std::cout << "
\033[1;30mExecute Time: " << std::chrono::duration_cast<std::chrono::microseconds>(end2 - begin2).count() / 1000 << "s \033[0m
";}
result
x::xstrExecute Time: 6s std::stringExecute Time: 38s
You can access the source code here: cpp xstring by xeerx
Original Link: https://dev.to/xeerx/i-created-a-string-system-faster-than-the-stdstring-4eli
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To