Source code:
#include <iostream>
#include <chrono>
using namespace std;
int main(int argc, char* argv[])
{
auto startTime =
chrono::high_resolution_clock::now();
for (int i=0;
i<123456789; ++i)
{
//for loop for nothing
}
chrono::nanoseconds
duration = chrono::high_resolution_clock::now()
- startTime;
cout << "Total time taken is "
<<
duration.count()
<< " nanoseconds.\n";
return 0;
}
Sample output:
Total time taken is 387022000 nanoseconds.
Notes:
387022000 nanoseconds
= 387022000 * 10^-9 seconds
= 387022000 * 10^-9 * 10^3 * 10^-3 seconds
= 387022000 * 10^-9 * 10^3 milliseconds
= 387022000 * 10^-6 milliseconds
= 387.022 milliseconds
Reading. Practice. Writing.
Please feel free to comment. Suggestions are also welcomed here. Write something "wholesome serving purpose" here.
Subscribe to:
Post Comments (Atom)
AI Doomsday
AI apocalypse AI extinction risk AI catastrophic AI was going to be the end of humanity. AI could kill all humans! AI leading to human extin...
-
DiGi Super Long Life is a feature where you can extend your talktime validity to 1 year for just RM30. Indirectly, the subscription fee is...
-
Subject: Use CodeBlocks to generate Nassi–Shneiderman Diagrams (NSDs) automatically What is the Nassi-Shneiderman Diagram? The Nassi-Shneide...
-
Open LibreOffice Draw program. Select the rectangle shape from shape toolbar at the bottom of drawing page. Click a point and drag-and-re...
No comments:
Post a Comment