Created
November 23, 2009 17:27
-
-
Save stepancheg/241214 to your computer and use it in GitHub Desktop.
sort.cpp
This file contains hidden or 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 <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