* [LTP] [PATCH] fs/fsx-linux/fsx-linux.c: Add measurement of execution time
@ 2023-08-08 6:20 Xin Wang via ltp
2023-08-10 8:04 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Xin Wang via ltp @ 2023-08-08 6:20 UTC (permalink / raw)
To: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [LTP] [PATCH] fs/fsx-linux/fsx-linux.c: Add measurement of execution time
2023-08-08 6:20 [LTP] [PATCH] fs/fsx-linux/fsx-linux.c: Add measurement of execution time Xin Wang via ltp
@ 2023-08-10 8:04 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2023-08-10 8:04 UTC (permalink / raw)
To: Xin Wang; +Cc: ltp
Hi!
> 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);
gettimeofday() is not a good way how to measure elapsed time, it may
jump up and down as it's adjusted by ntp-daemon.
If you want to measure time between two events you should use
clock_gettime() with CLOCK_MONOTONIC_RAW instead.
> 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
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-10 8:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-08 6:20 [LTP] [PATCH] fs/fsx-linux/fsx-linux.c: Add measurement of execution time Xin Wang via ltp
2023-08-10 8:04 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox