Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // g++ -O3 std=c++0x filename.cpp -o filename.out
- #include <chrono>
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- char buf[4096];
- void clrscr()
- {
- #ifdef _WIN32
- system("CLS");
- #else
- system("clear");
- #endif
- }
- int main()
- {
- using namespace std;
- enum { TIMES = 40960 };
- #ifdef USE_BUFFER
- cout.rdbuf()->pubsetbuf(buf, sizeof(buf));
- #endif
- getchar();
- clrscr();
- auto timer = std::chrono::system_clock::now();
- for (int i=0; i!=TIMES; ++i)
- cout << "asdfghjklasdfghjklasdfghjkl;asdfghjklasdfghjklasdfghjkl;\n";
- cout.flush();
- auto t1 = std::chrono::system_clock::now() - timer;
- clrscr();
- timer = std::chrono::system_clock::now();
- for (int i=0; i!=TIMES; ++i)
- printf("%s", "asdfghjklasdfghjklasdfghjkl;asdfghjklasdfghjklasdfghjkl;\n");
- fflush(stdout);
- auto t2 = std::chrono::system_clock::now() - timer;
- clrscr();
- timer = std::chrono::system_clock::now();
- for (int i=0; i!=TIMES; ++i)
- printf("asdfghjklasdfghjklasdfghjkl;asdfghjklasdfghjklasdfghjkl;\n");
- fflush(stdout);
- auto t3 = std::chrono::system_clock::now() - timer;
- clrscr();
- cout << t1.count() << endl << t2.count() << endl << t3.count() << endl;
- }
Add Comment
Please, Sign In to add comment