error.c 633 B

1234567891011121314151617181920212223242526
  1. // This simple benchmark measures how long it takes to get 1M errors.
  2. // It will be used to improve waserror performance, as that is a crucial
  3. // bit of code in some paths and Akaros has shown how to get it back to
  4. // Ken C-like performance levels.
  5. #include <u.h>
  6. #include <libc.h>
  7. void
  8. main(int argc, char *argv[])
  9. {
  10. int i;
  11. uint64_t start, stop;
  12. char buf[1];
  13. (void) close(3);
  14. start = nsec();
  15. for(i = 0; i < 1000000000; i++) {
  16. if (read(3, buf, 1) >= 0){
  17. fprint(2, "Read of 3 did not fail!\n");
  18. exits("benchmark broken");
  19. }
  20. }
  21. stop = nsec();
  22. print("# error benchmark\n");
  23. print("1000000 %lld\n", stop - start);
  24. }