Skip to content

Instantly share code, notes, and snippets.

@stepancheg
Created November 23, 2009 17:27
Show Gist options
  • Save stepancheg/241214 to your computer and use it in GitHub Desktop.
Save stepancheg/241214 to your computer and use it in GitHub Desktop.
sort.cpp
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
uint64_t us() {
struct timeval tv;
gettimeofday(&tv, 0);
return 1LL * tv.tv_sec * 1000 * 1000 + tv.tv_usec;
}
int main() {
srandom(time(0));
for (;;) {
std::vector<int> v;
for (int i = 0; i < 20 * 1000 * 1000; ++i) {
v.push_back(int(random()));
}
uint64_t start = us();
sort(v.begin(), v.end());
uint64_t end = us();
cerr << end - start << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment