Skip to content

Instantly share code, notes, and snippets.

@niklas88
Last active February 28, 2018 11:18
Show Gist options
  • Save niklas88/6074582e6c0647d59100640bf9b82085 to your computer and use it in GitHub Desktop.
Save niklas88/6074582e6c0647d59100640bf9b82085 to your computer and use it in GitHub Desktop.
#include <chrono>
#include <iostream>
#include <algorithm>
#include <array>
int main(int argc, char** argv) {
std::array<int, 13> arr = {12, 5, 7, 9, 2, 2, 33, 24, 1, 8, 0, 3, 77};
auto start = std::chrono::high_resolution_clock::now();
std::sort(arr.begin(), arr.end());
auto end = std::chrono::high_resolution_clock::now();
auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
std::cout << "Took " << nanoseconds << " nanoseconds" << std::endl;
for (int val : arr) {
std::cout << val << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment