fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. void minhafuncao() {
  5. int x = 0;
  6. x++;
  7. // return x;
  8. }
  9.  
  10. int main () {
  11. clock_t begin, end;
  12. double time_spent;
  13. int x;
  14. begin = clock();
  15. for (int i = 0; i < 300000000; i++);
  16. end = clock();
  17. time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  18. printf ("Tempo gasto %.2lf segundos.\n", time_spent);
  19. begin = clock();
  20. for (int i = 0; i < 300000000; i++) minhafuncao();
  21. end = clock();
  22. time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  23. printf ("Tempo gasto %.2lf segundos.\n", time_spent);
  24. begin = clock();
  25. for (int i = 0; i < 300000000; i++) x++;
  26. end = clock();
  27. time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  28. printf ("Tempo gasto %.2lf segundos.\n", time_spent);
  29. x++;
  30. }
  31.  
  32. //https://pt.stackoverflow.com/q/57664/101
Success #stdin #stdout 1.63s 4444KB
stdin
Standard input is empty
stdout
Tempo gasto 0.47 segundos.
Tempo gasto 0.55 segundos.
Tempo gasto 0.60 segundos.