[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppTimer

(C++) boost::timer

Class from the Boost Timer library.

  1. include <iostream>
  2. include <boost/timer.hpp>
int main() { boost::timer t; for (int i=0; i<10000000; ++i) std::rand(); std::cout << t.elapsed() << std::endl; }


Same example using the Standard library

Using std::clock.

// Note: shouldn't it be std::clock_t ?
  1. include <iostream>
  2. include <ctime>
int main() { const clock_t begin = std::clock(); for (int i=0; i<10000000; ++i) std::rand(); const clock_t end = std::clock(); std::cout << "Time of STL rand(): " << std::difftime(end,begin) << std::endl; }


Code links



last edited (February 8, 2007) by bilderbikkel, Number of views: 1059, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.