From: Cyril Hrubis <chrubis@suse.cz>
To: Xin Wang <Xin.Wang@windriver.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] fs/fsx-linux/fsx-linux.c: Add measurement of execution time
Date: Thu, 10 Aug 2023 10:04:40 +0200 [thread overview]
Message-ID: <ZNSaGP9_SRoAiHMX@yuki> (raw)
In-Reply-To: <20230808062025.2991984-1-Xin.Wang@windriver.com>
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
prev parent reply other threads:[~2023-08-10 8:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZNSaGP9_SRoAiHMX@yuki \
--to=chrubis@suse.cz \
--cc=Xin.Wang@windriver.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox