11
int main(int argc, char *argv[]) {
16
struct timeval start, tv;
19
size_t total_size = 0;
25
printf("Usage: %s <directory> [skip]\n", argv[0]);
34
printf("Skip %i\n", SKIP);
37
gettimeofday(&start, NULL);
38
for (run = 0; run < SKIP; run++) {
41
while (ent = readdir(dir)) {
44
if (((skip++)%SKIP) != run) continue;
46
if (stat(ent->d_name, &st)) continue;
47
if (!S_ISREG(st.st_mode)) continue;
49
FILE *f = fopen(ent->d_name, "r");
52
int size = st.st_blksize;
55
printf("Buffer too small\n");
60
err = fread(buffer, 1, size, f);
62
printf("Read failed\n");
69
total_size += st.st_size;
72
gettimeofday(&tv, NULL);
73
us = (tv.tv_sec - start.tv_sec) * 1000000 + (tv.tv_usec - start.tv_usec);
74
printf("Reading: %s (%lu MB), Read: %lu files (%lu GB), Measured speed: %lu mB/s\n", ent->d_name, st.st_size/1024/1024, files, total_size / 1024 / 1024 / 1024, total_size / us);
b'\\ No newline at end of file'