Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * puts vs printf test
- *
- */
- #include <stdio.h>
- #include <time.h>
- #define LOOP 100000
- int main(int argc, char *argv[]) {
- int i;
- clock_t t1, t2;
- double tdiff_puts, tdiff_printf;
- t1 = clock();
- for(i=0; i<LOOP; ++i)
- puts("Hello World");
- t2 = clock();
- tdiff_puts = (double)(t2-t1) / CLOCKS_PER_SEC;
- t1 = clock();
- for(i=0; i<LOOP; ++i)
- printf("Hello World\n");
- t2 = clock();
- tdiff_printf = (double)(t2-t1) / CLOCKS_PER_SEC;
- printf("CPU Time puts: %f\n", tdiff_puts);
- printf("CPU Time printf: %f\n", tdiff_printf);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement