From dbc31f20d30615404c2994f2d0bb9876cd75585a Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 2 Oct 2017 13:56:25 +0200 Subject: libbacktrace: Conditionalize test timing on clock_gettime availability libbacktrace/ PR other/67165 * configure.ac: Check for clock_gettime. * config.h.in: Regenerate. * configure: Likewise. * ztest.c (average_time, test_large): Conditionalize test timing on clock_gettime availability. From-SVN: r253344 --- libbacktrace/ztest.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libbacktrace/ztest.c') diff --git a/libbacktrace/ztest.c b/libbacktrace/ztest.c index 103ad65..0b1cbc3 100644 --- a/libbacktrace/ztest.c +++ b/libbacktrace/ztest.c @@ -43,6 +43,10 @@ POSSIBILITY OF SUCH DAMAGE. */ #include #endif +#ifdef HAVE_CLOCK_GETTIME +# define TEST_TIMING +#endif + #include "backtrace.h" #include "backtrace-supported.h" @@ -157,7 +161,7 @@ test_samples (struct backtrace_state *state) } } -#ifdef HAVE_ZLIB +#if defined HAVE_ZLIB && defined TEST_TIMING /* Given a set of TRIALS timings, discard the lowest and highest values and return the mean average of the rest. */ @@ -216,6 +220,7 @@ test_large (struct backtrace_state *state) unsigned char *uncompressed_buf; size_t uncompressed_bufsize; int r; +# ifdef TEST_TIMING clockid_t cid; struct timespec ts1; struct timespec ts2; @@ -224,6 +229,7 @@ test_large (struct backtrace_state *state) const size_t trials = 16; size_t ctimes[16]; size_t ztimes[16]; +# endif /* TEST_TIMING */ static const char * const names[] = { "Mark.Twain-Tom.Sawyer.txt", "../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt" @@ -341,6 +347,8 @@ test_large (struct backtrace_state *state) printf ("PASS: inflate large\n"); +# ifdef TEST_TIMING + for (i = 0; i < trials; ++i) { cid = CLOCK_REALTIME; @@ -411,6 +419,8 @@ test_large (struct backtrace_state *state) printf ("zlib time: : %zu ns\n", ztime); printf ("percentage : %g\n", (double) ztime / (double) ctime); +# endif /* TEST_TIMING */ + return; fail: -- cgit v1.1