run_timer_example2.cpp 661 B

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