74
75
struct io_event ev[AIO_MODE];
75
76
#endif /* AIO_MODE */
81
printf("Used buffer: %i MB, Block: %i KB\n", BUFSIZE / 1024 / 1024, BLOCK_SIZE/1024);
83
79
posix_memalign((void**)&buffer, FASTWRITER_SYNCIO_ALIGN, BUFSIZE);
93
89
max_size *= 1024 * 1024 * 1024;
96
printf("Used buffer: %i MB, Block: %i KB\n", BUFSIZE / 1024 / 1024, BLOCK_SIZE/1024);
96
99
int fd = open(argv[1], flags, 0);
98
101
printf("Unable to open device %s\n", argv[1]);
239
246
if (stat(ent->d_name, &st)) continue;
240
247
if (!S_ISREG(st.st_mode)) continue;
249
int size = st.st_blksize;
243
252
FILE *f = fopen(ent->d_name, "r");
244
253
if (!f) continue;
246
255
int fd = open(ent->d_name, flags, 0);
247
256
if (fd < 0) continue;
259
if (size < BLOCK_SIZE) size = BLOCK_SIZE;
260
# endif /* FS_SYNC_MODE */
250
int size = st.st_blksize;
264
printf("Reading %s, Block: %i KB\n", ent->d_name, size / 1024);
252
266
if (size > BUFSIZE) {
253
267
printf("Buffer too small\n");
271
size_t last_file_write = 0;
272
size_t last_file_size = 0;
273
size_t file_size = 0;
274
gettimeofday(&fstart, NULL);
259
277
while (!feof(f)) {
260
err = fread(buffer, 1, size, f);
278
ssize_t ret = fread(buffer, 1, size, f);
265
if (size < BLOCK_SIZE) size = BLOCK_SIZE;
267
err = read(fd, buffer, size);
269
err = read(fd, buffer, size);
281
ssize_t ret = read(fd, buffer, size);
287
gettimeofday(&tv, NULL);
288
us = (tv.tv_sec - fstart.tv_sec) * 1000000 + (tv.tv_usec - fstart.tv_usec);
290
if ((us - last_file_write) > WRITE_INTERVAL * 1000000) {
291
printf("Reading: %s (%lu GB), Measured speed: %zu MB/s, Current speed: %zu MB/s\n", ent->d_name, file_size / 1024 / 1024 / 1024, (size_t)(mcoef * file_size / us), (size_t)(mcoef * (file_size - last_file_size) / (us - last_file_write)));
292
last_file_write = us;
293
last_file_size = file_size;
274
298
printf("Read failed\n");
287
311
gettimeofday(&tv, NULL);
288
312
us = (tv.tv_sec - start.tv_sec) * 1000000 + (tv.tv_usec - start.tv_usec);
289
printf("Reading: %s (%lu MB), Read: %lu files (%lu GB), Measured speed: %zu MB/s\n", ent->d_name, st.st_size/1024/1024, files, total_size / 1024 / 1024 / 1024, (size_t)(mcoef * total_size / us));
313
if ((us - last_write) > WRITE_INTERVAL * 1000000) {
315
printf("Read: %lu files (%lu GB) at %zu MB/s", files, total_size / 1024 / 1024 / 1024, (size_t)(mcoef * total_size / us));
317
us = (tv.tv_sec - fstart.tv_sec) * 1000000 + (tv.tv_usec - fstart.tv_usec);
318
printf(", Last: %s (%lu MB) at %zu MB/s\n", ent->d_name, st.st_size/1024/1024, (size_t)(mcoef * file_size / us));
323
us = (tv.tv_sec - start.tv_sec) * 1000000 + (tv.tv_usec - start.tv_usec);
324
printf("Total: %lu files (%lu GB) at %zu MB/s\n", files, total_size / 1024 / 1024 / 1024, (size_t)(mcoef * total_size / us));