c语言统计程序执行时间
c语言程序执行时间
#include <iostream> #include <cstdio> #include <ctime> int main() { std::clock_t start; double duration; start = std::clock(); int i, sum; for(i=1; i<100000000; i++){ sum+=i; } /* Your algorithm here */ duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC; std::cout<<"printf: "<< duration <<'\n'; }