Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uint64_t t1 = 0, t2 = 0, t3 = 0;
- Chrono now;
- for (uint32_t i = 0; i < 100000; ++i)
- {
- char* buf = new char[16];
- strcpy(buf, "blabla");
- delete buf;
- }
- t1 = now.Milliseconds();
- now.Reset();
- FILE* f = fopen("temp.txt", "w");
- for (uint32_t i = 0; i < 100000; ++i)
- {
- fprintf(f, "blabla");
- }
- fclose(f);
- t2 = now.Milliseconds();
- now.Reset();
- for (uint32_t i = 0; i < 100000; ++i)
- {
- std::cout << "blabla";
- }
- t3 = now.Milliseconds();
- std::cout << std::endl;
- std::cout << "Memcpy: " << t1 << " ms" << std::endl; // 5 ms
- std::cout << "file: " << t2 << " ms" << std::endl; // 30 ms
- std::cout << "cout: " << t3 << " ms" << std::endl; // 14274 ms
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement