diff --git a/timecheck.cpp b/timecheck.cpp new file mode 100644 index 0000000..68c7a55 --- /dev/null +++ b/timecheck.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include +using namespace std; +using namespace std::chrono; +int main() +{ + + vector values(10000); + + // Generate Random values + auto f = []() -> int { return rand() % 10000; }; + + // Fill up the vector + generate(values.begin(), values.end(), f); + + // Get starting timepoint + auto start = high_resolution_clock::now(); + + // Call the function, here sort() + sort(values.begin(), values.end()); + + // Get ending timepoint + auto stop = high_resolution_clock::now(); + + // Get duration. Substart timepoints to + // get durarion. To cast it to proper unit + // use duration cast method + auto duration = duration_cast(stop - start); + + cout << "Time taken by function: " + << duration.count() << " microseconds" << endl; + + return 0; +}