|
|
1.1 ! root 1: /* ! 2: * Sequential I/O benchmark. ! 3: */ ! 4: ! 5: #include <sys/types.h> ! 6: #include <sys/file.h> ! 7: #include <sys/stat.h> ! 8: ! 9: char *malloc(); ! 10: ! 11: main(argc, argv) ! 12: char *argv[]; ! 13: { ! 14: register int i, max; ! 15: char *buf; ! 16: struct stat sb; ! 17: int fd; ! 18: ! 19: if (argc < 3) { ! 20: printf("usage: %s file megabytes\n", argv[0]); ! 21: exit(1); ! 22: } ! 23: fd = open(argv[1], O_WRONLY|O_CREAT|O_TRUNC, 0644); ! 24: if (fd < 0) { ! 25: perror(argv[1]); ! 26: exit(1); ! 27: } ! 28: fstat(fd, &sb); ! 29: buf = malloc(sb.st_blksize); ! 30: max = (atoi(argv[2]) * 1024 * 1024) / sb.st_blksize; ! 31: printf("%d writes of %d kilobytes\n", max, sb.st_blksize / 1024); ! 32: for (i = 0; i < max; i++) ! 33: write(fd, buf, sb.st_blksize); ! 34: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.