1 // run_timer_example.cpp ---------------------------------------------------// 2 3 // Copyright Beman Dawes 2006, 2008 4 5 // Distributed under the Boost Software License, Version 1.0. 6 // See http://www.boost.org/LICENSE_1_0.txt 7 8 // See http://www.boost.org/libs/chrono for documentation. 9 10 #include <boost/chrono/process_times.hpp> 11 #include <cmath> 12 main(int argc,char * argv[])13int main( int argc, char * argv[] ) 14 { 15 const char * format = argc > 1 ? argv[1] : "%t cpu seconds\n"; 16 int places = argc > 2 ? std::atoi( argv[2] ) : 2; 17 18 boost::chrono::run_timer t( format, places ); 19 20 for ( long i = 0; i < 10000; ++i ) 21 std::sqrt( 123.456L ); // burn some time 22 23 return 0; 24 } 25