[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppTimeH
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:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
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:
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; }
- include <iostream>
- include <time>
Same example using the Boost C++ library
int main() { boost::timer t; for (int i=0; i!=10000000; ++i) std::rand(); std::cout << t.elapsed() << std::endl; return 0; }
- include <iostream>
- include <boost/timer.hpp>
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.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
