From da8c666e4fae66d58ce8bfb6cf48f91ec47f38c6 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 20 Feb 2007 01:09:38 +0000 Subject: add tutil_tvdiff_secs() for completeness --- tests/libtest/testutil.c | 11 +++++++++++ tests/libtest/testutil.h | 7 +++++++ 2 files changed, 18 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index 6acd5a71b..dc0211026 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -98,6 +98,17 @@ long tutil_tvdiff(struct timeval newer, struct timeval older) (newer.tv_usec-older.tv_usec)/1000; } +/* + * Same as tutil_tvdiff but with full usec resolution. + * + * Returns: the time difference in seconds with subsecond resolution. + */ +double tutil_tvdiff_secs(struct timeval newer, struct timeval older) +{ + return (double)(newer.tv_sec-older.tv_sec)+ + (double)(newer.tv_usec-older.tv_usec)/1000000.0; +} + /* return the number of seconds in the given input timeval struct */ long tutil_tvlong(struct timeval t1) { diff --git a/tests/libtest/testutil.h b/tests/libtest/testutil.h index 18bd9e99c..e248c1ebe 100644 --- a/tests/libtest/testutil.h +++ b/tests/libtest/testutil.h @@ -56,6 +56,13 @@ struct timeval tutil_tvnow(void); */ long tutil_tvdiff(struct timeval t1, struct timeval t2); +/* + * Same as tutil_tvdiff but with full usec resolution. + * + * Returns: the time difference in seconds with subsecond resolution. + */ +double tutil_tvdiff_secs(struct timeval t1, struct timeval t2); + long tutil_tvlong(struct timeval t1); -- cgit v1.2.3