How do I call clock() in C++?
clock()
C++
For example, I want to test how much time a linear search takes to find a given element in an array.
#include <iostream> #include <cstdio> #include <ctime> int main() { std::clock_t start; double duration; start = std::clock(); /* Your algorithm here */ duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC; std::cout<<"printf: "<< duration <<' '; }
1.4m articles
1.4m replys
5 comments
57.0k users