[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppTimer
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppTimer
(C++) boost::timer
Class from the Boost Timer library.int main() { boost::timer t; for (int i=0; i<10000000; ++i) std::rand(); std::cout << t.elapsed() << std::endl; }
- include <iostream>
- include <boost/timer.hpp>
Same example using the Standard library
Using std::clock.// Note: shouldn't it be std::clock_t ?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; }
- include <iostream>
- include <ctime>
Code links
- #include
- char
- const
- cout
- ctime (header file)
- difftime
- endl
- for
- include
- int
- iostream (header file)
- main
- std
- std::cout
- std::difftime
- std::endl
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
