mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 00:06:34 +00:00
Add the throughput for file_io
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
82220748c0
commit
f19dfc7873
@ -47,6 +47,7 @@ int perform_sequential_io(int fd, ssize_t (*io_func)(int, void *, size_t),
|
|||||||
char buffer[BUFFER_SIZE];
|
char buffer[BUFFER_SIZE];
|
||||||
ssize_t ret, offset = 0;
|
ssize_t ret, offset = 0;
|
||||||
long total_nanoseconds = 0, avg_latency;
|
long total_nanoseconds = 0, avg_latency;
|
||||||
|
double throughput;
|
||||||
|
|
||||||
memset(buffer, 0, BUFFER_SIZE);
|
memset(buffer, 0, BUFFER_SIZE);
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
@ -67,9 +68,12 @@ int perform_sequential_io(int fd, ssize_t (*io_func)(int, void *, size_t),
|
|||||||
}
|
}
|
||||||
|
|
||||||
avg_latency = total_nanoseconds / NUM_OF_CALLS;
|
avg_latency = total_nanoseconds / NUM_OF_CALLS;
|
||||||
|
throughput = ((double)BUFFER_SIZE * NUM_OF_CALLS) /
|
||||||
|
((double)total_nanoseconds / 1e9);
|
||||||
printf("Executed the sequential %s (buffer size: %dKB, file size: %dMB) syscall %d times.\n",
|
printf("Executed the sequential %s (buffer size: %dKB, file size: %dMB) syscall %d times.\n",
|
||||||
op_name, BUFFER_SIZE / KB, FILE_SIZE / MB, NUM_OF_CALLS);
|
op_name, BUFFER_SIZE / KB, FILE_SIZE / MB, NUM_OF_CALLS);
|
||||||
printf("Syscall average latency: %ld nanoseconds.\n", avg_latency);
|
printf("Syscall average latency: %ld nanoseconds, throughput: %.2f MB/s\n",
|
||||||
|
avg_latency, throughput / MB);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user