[LTP] [PATCH] fs/fsx-linux/fsx-linux.c: Add measurement of execution time
Xin Wang
Xin.Wang@windriver.com
Tue Aug 8 08:20:25 CEST 2023
fsx-linux.c is usually used for file system regression testing and total execution time also more and more receives attention.
Add measurement of execution time in fsx-linux.c:
[fsx-linux]$ PATH=$PATH:$PWD ./fsx-linux -N 20000 /tmp/test/test.ini
All operations completed A-OK!
Elapsed Test Time 0.388891
Signed-off-by: Xin.Wang@windriver.com
---
testcases/kernel/fs/fsx-linux/fsx-linux.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/fs/fsx-linux/fsx-linux.c b/testcases/kernel/fs/fsx-linux/fsx-linux.c
index 64c27a0f5..71b719782 100644
--- a/testcases/kernel/fs/fsx-linux/fsx-linux.c
+++ b/testcases/kernel/fs/fsx-linux/fsx-linux.c
@@ -1115,7 +1115,8 @@ int main(int argc, char **argv)
int i, style, ch;
char *endp;
int dirpath = 0;
-
+ struct timeval time_start, time_end, time_diff;
+
goodfile[0] = 0;
logfile[0] = 0;
@@ -1336,12 +1337,24 @@ int main(int argc, char **argv)
} else
check_trunc_hack();
+ gettimeofday(&time_start, NULL);
while (numops == -1 || numops--)
test();
close_test_files();
+ gettimeofday(&time_end, NULL);
+
prt("All operations completed A-OK!\n");
+ time_diff.tv_sec = time_end.tv_sec - time_start.tv_sec;
+ time_diff.tv_usec = time_end.tv_usec - time_start.tv_usec;
+ if (time_diff.tv_usec < 0) {
+ time_diff.tv_usec += 1000000;
+ time_diff.tv_sec -= 1;
+ }
+ prt("Elapsed Test Time %lu.%06lu\n",
+ (unsigned long)time_diff.tv_sec, time_diff.tv_usec);
+
if (tf_buf)
free(tf_buf);
--
2.34.1
More information about the ltp
mailing list