Skip to content

Instantly share code, notes, and snippets.

@akshaynanavati
Created September 24, 2018 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akshaynanavati/39a7f949575c01dfeb646a4aa12f1752 to your computer and use it in GitHub Desktop.
Save akshaynanavati/39a7f949575c01dfeb646a4aa12f1752 to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <chrono>
#include <ctime>
#include <iostream>
#include <random>
#include <vector>
std::string randString() {
std::mt19937 rng(time(NULL));
std::string s(64, '\0');
std::generate(s.begin(), s.end(), rng);
return s;
}
int main() {
std::mt19937_64 rng(time(NULL));
std::vector<std::string> v(1000000);
std::generate(v.begin(), v.end(), randString);
auto t1 = std::chrono::high_resolution_clock::now();
std::sort(v.begin(), v.end());
auto d = std::chrono::high_resolution_clock::now() - t1;
asm volatile("" : : : "memory");
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(d).count()
<< std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment