NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
chronoTest.cpp
1 #include <iostream>
2 #include <boost/chrono.hpp>
3 //#include <chrono>
4 #include <ctime>
5 
6 long fibonacci(unsigned n)
7 {
8  if (n < 2) return n;
9  return fibonacci(n-1) + fibonacci(n-2);
10 }
11 
12 int main()
13 {
14  boost::chrono::time_point<boost::chrono::system_clock> start, end;
15  start = boost::chrono::system_clock::now();
16  std::cout << "f(42) = " << fibonacci(42) << '\n';
17  end = boost::chrono::system_clock::now();
18 
19  boost::chrono::duration<double> elapsed_seconds = end-start;
20  std::time_t end_time = boost::chrono::system_clock::to_time_t(end);
21 
22  std::cout << "finished computation at " << std::ctime(&end_time)
23  << "elapsed time: " << elapsed_seconds.count() << "s\n";
24 }
int main(int argc, char **argv)