This content originally appeared on DEV Community and was authored by Maysara
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 << "\n\033[1;30mExecute Time: " << std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count() / 1000 << "µs \033[0m\n";
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 << "\n\033[1;30mExecute Time: " << std::chrono::duration_cast<std::chrono::microseconds>(end2 - begin2).count() / 1000 << "µs \033[0m\n";
}
result
x::xstr
Execute Time: 6µs
std::string
Execute Time: 38µs
You can access the source code here: cpp xstring by xeerx
This content originally appeared on DEV Community and was authored by Maysara
Maysara | Sciencx (2022-04-01T13:14:51+00:00) I created a string system faster than the std::string!. Retrieved from https://www.scien.cx/2022/04/01/i-created-a-string-system-faster-than-the-stdstring/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.