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

(C++) std::clock_t

Struct containing time information. Returned e.g. by the Function clock .

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

  1. include <iostream>
  2. include <ctime>
int main() { const std::clock_t begin = std::clock(); for (int i=0; i<10000000; ++i) std::rand(); const std::clock_t end = std::clock(); std::cout << "Time of STL rand(): " << std::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; }


Topic links



last edited (March 21, 2007) by bilderbikkel, Number of views: 2882, Current Rev: 8 (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.