2 #include <boost/chrono.hpp>
6 long fibonacci(
unsigned n)
9 return fibonacci(n-1) + fibonacci(n-2);
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();
19 boost::chrono::duration<double> elapsed_seconds = end-start;
20 std::time_t end_time = boost::chrono::system_clock::to_time_t(end);
22 std::cout <<
"finished computation at " << std::ctime(&end_time)
23 <<
"elapsed time: " << elapsed_seconds.count() <<
"s\n";
int main(int argc, char **argv)