I want to find the time it will take to sort through an insertion sort in c++?

I want to ask a user to enter 10 random numbers. The program will sort through this array of numbers using insertion sort. The program will then display the sorted array and the time it took to sort the array in c++.
April 4th 20 at 00:32
1 answer
April 4th 20 at 00:34
Solution
auto t1 = std::chrono::high_resolution_clock::now();
f();
auto t2 = std::chrono::high_resolution_clock::now();


Examples
https://en.cppreference.com/w/cpp/chrono/high_reso...
FROM -----> https://en.cppreference.com/w/cpp/chrono/duration/...
https://en.cppreference.com/w/cpp/chrono/c/difftime
Thank you for your feedback. I wanted you to implement an insertion sort algorithm which calculates the time it will take to sort the values. - Justice.Gutmann commented on April 4th 20 at 00:37
@Justice.Gutmann,
https://www.geeksforgeeks.org/insertion-sort/
https://www.geeksforgeeks.org/insertion-sort-using...

// ...
auto t1 = std::chrono::high_resolution_clock::now();
insertionSort(...)
auto t2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> fp_ms = t2 - t1;
std::cout << "insertionSort( ... ) took" << fp_ms.count() << " ms " << "\n";
- Esther_Hick commented on April 4th 20 at 00:40

Find more questions by tags C++