/* Put this statement before main. */ #include /* Put these declaration statements at the beginning, when you declare other local variables. */ clock_t starttime, endtime; double elapsed; /* This statement substitutes for Matlab’s tic. */ starttime = clock(); /* Do the work. When working with any timer, beware of inaccuracies: -- If the work takes too long (not an issue in this assignment), the counter can roll over to zero (like the odometer on an old car) and timing will be inaccurate. -- If the work takes too little time, the "random" noise in the count will be a large percentage of the measurement. If necessary, do the work S times between the two calls to clock, where S is chosen to make the difference in starttime and endtime about CLOCKS_PER_SEC, and divide elapsed by S. */ /* These two statements substitute for Matlab’s toc. */ endtime = clock(); elapsed = ((double) (endtime - starttime)) / CLOCKS_PER_SEC; /* Reference: http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/ library_19.html#SEC310 */