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

(C++) time (header file)

Header file containing time-related functions and structs.

time is not a C++ standard header file [1,2], but ctime is [2].

The example below shows how to test the speed of the STL's rand function:

  1. include <iostream>
  2. include <time>
int main() { const clock_t begin = clock(); for (int i=0; i!=10000000; ++i) std::rand(); const clock_t end = clock(); std::cout << "Time of STL rand(): " << difftime(end,begin) << std::endl; }


Same example using the Boost C++ 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; return 0; }


Topic links

References

  • 1) C++ International Standard. ISO/IEC 14882. Second edition. Table 11.
  • 2) C++ International Standard. ISO/IEC 14882. Second edition. Table 12.


last edited (November 18, 2006) by bilderbikkel, Number of views: 2840, Current Rev: 9 (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.