Created
February 6, 2014 16:39
-
-
Save yukoba/8847880 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <queue> | |
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
using namespace std; | |
void benchmark(int len) | |
{ | |
priority_queue<int> q; | |
clock_t start = clock(); | |
for (int i = 0; i < len; i++) { | |
q.push(rand()); | |
} | |
clock_t end = clock(); | |
cout << "len = " << len << ", time = " << (end - start) / (double) CLOCKS_PER_SEC << endl; | |
} | |
int main() | |
{ | |
benchmark(1000 * 1000); | |
benchmark(10 * 1000 * 1000); | |
benchmark(100 * 1000 * 1000); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment