Skip to content

Instantly share code, notes, and snippets.

@yukoba
Created February 6, 2014 16:39
Show Gist options
  • Save yukoba/8847880 to your computer and use it in GitHub Desktop.
Save yukoba/8847880 to your computer and use it in GitHub Desktop.
#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