[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppCtimeH
ctime is a C++ standard header file [2], but time is not [1,2].
The example below shows how to test the speed of the STL's std::rand function:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppCtimeH
(C++) ctime (header file)
C++ Standard header file for C library facilities [2]. It contains time-related functions and structs.ctime is a C++ standard header file [2], but time is not [1,2].
The example below shows how to test the speed of the STL's std::rand function:
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>
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; }
- include <iostream>
- include <boost/timer.hpp>
Code links
C++ Library headers
From [1].- algorithm
- bitset
- complex
- deque
- exception
- fstream
- functional
- iomanip
- ios
- iosfwd
- iostream
- istream
- iterator
- limits
- list
- locale
- map
- memory
- new
- numeric
- ostream
- queue
- set
- sstream
- stack
- stdexcept
- streambuf
- string
- strstream
- typeinfo
- utility
- valarray
- vector
C++ Headers for C library facilities
From [2].- cassert
- cctype
- cerrno
- cfloat
- ciso646
- climits
- clocale
- cmath
- csetjmp
- csignal
- cstdarg
- cstddef
- cstdio
- cstdlib
- cstring
- ctime
- cwchar
- cwctype
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]
