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.
Saturday
Friday
MinGW g++: error: CreateProcess: No such file or directory (solved)
Problem:
C:\MinGW\bin>g++ --version
g++ (GCC) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\MinGW\bin>g++ cpp_v1.cpp
g++: error: CreateProcess: No such file or directory
Solution:
Uninstall the old CodeBlocks program from your PC.
Note:
Do this, only if you want to try C++11 or C++0x.
C:\MinGW\bin>g++ --version
g++ (GCC) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\MinGW\bin>g++ cpp_v1.cpp
g++: error: CreateProcess: No such file or directory
Solution:
Uninstall the old CodeBlocks program from your PC.
Note:
Do this, only if you want to try C++11 or C++0x.
Subscribe to:
Posts (Atom)
C++32 (or C++2e), C++ 2032, Cpp 2032, g++ 2032
Subject: C++ 2032 3 Code example for ? 2 Approximate feature suggestions: - to complete C++29 or C++ 2029 1 Web links, references Wandbox,...
-
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...
-
Open LibreOffice Draw program. Select the rectangle shape from shape toolbar at the bottom of drawing page. Click a point and drag-and-re...
-
DiGi Super Long Life is a feature where you can extend your talktime validity to 1 year for just RM38. Indirectly, the subscription fee is ...