Created
September 24, 2018 00:39
-
-
Save akshaynanavati/39a7f949575c01dfeb646a4aa12f1752 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 <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