fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5.  
  6. int main() {
  7. int buflen = 1 << 20;
  8. char* buf = malloc(buflen);
  9. FILE* pf = fopen("/dev/null", "w");
  10. clock_t start;
  11. int i;
  12. unsigned long long int written = 0;
  13. memset(buf, 0, buflen);
  14. start = clock();
  15. while (((float)(clock() - start)) / CLOCKS_PER_SEC < 0.95) {
  16. for (i = 0; i < 1000; ++i) {
  17. written += fwrite(buf, 1, buflen, pf);
  18. }
  19. }
  20. fclose(pf);
  21. free(buf);
  22. printf("time taken: %fs, bytes written: %llu\n",
  23. ((float)(clock() - start)) / CLOCKS_PER_SEC, written);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.96s 1808KB
stdin
Standard input is empty
stdout
time taken: 0.950000s, bytes written: 1071644672000