fork(2) download
  1. #include <algorithm>
  2. #include <cstring>
  3. #include <cstdio>
  4. #include <ctime>
  5.  
  6. using namespace std;
  7.  
  8. int A[1000 * 1000 * 100];
  9. clock_t clk;
  10. int main() {
  11. clk = clock();
  12. fill(A, A + 1000 * 1000 * 100, -1);
  13. printf("CPU Clocks : %d\n", clock() - clk);
  14. printf ("%d\n", A[1]);
  15. clk = clock();
  16. memset(A, -1, sizeof(A));
  17. printf("CPU Clocks : %d\n", clock() - clk);
  18. printf ("%d\n", A[1]);
  19. clk = clock();
  20. fill(A, A + 1000 * 1000 * 100, -1);
  21. printf("CPU Clocks : %d\n", clock() - clk);
  22. printf ("%d\n", A[1]);
  23. clk = clock();
  24. memset(A, -1, sizeof(A));
  25. printf("CPU Clocks : %d\n", clock() - clk);
  26. printf ("%d\n", A[1]);
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.69s 393984KB
stdin
Standard input is empty
stdout
CPU Clocks : 370000
-1
CPU Clocks : 80000
-1
CPU Clocks : 150000
-1
CPU Clocks : 90000
-1