diff --git a/time_comparison.c b/time_comparison.c new file mode 100644 index 0000000000000000000000000000000000000000..e84f3e7e420ddb5c07fd463cafabff890c4ce8ce --- /dev/null +++ b/time_comparison.c @@ -0,0 +1,25 @@ +/* Copyrights http://www.tutorialspoint.com/c_standard_library/c_function_clock.htm */ +#include <time.h> +#include <stdio.h> + +int main() +{ + clock_t start_t, end_t, total_t; + int i; + + start_t = clock(); + printf("Starting of the program, start_t = %ld\n", start_t); + + printf("Going to scan a big loop, start_t = %ld\n", start_t); + for(i=0; i< 10000000; i++) + { + } + end_t = clock(); + printf("End of the big loop, end_t = %ld\n", end_t); + + total_t = (double)(end_t - start_t) / CLOCKS_PER_SEC; + printf("Total time taken by CPU: %f\n", total_t ); + printf("Exiting of the program...\n"); + + return(0); +} \ No newline at end of file