aboutsummaryrefslogtreecommitdiff
path: root/libbacktrace/ztest.c
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2017-10-02 13:56:25 +0200
committerThomas Schwinge <tschwinge@gcc.gnu.org>2017-10-02 13:56:25 +0200
commitdbc31f20d30615404c2994f2d0bb9876cd75585a (patch)
tree6180153dd27e37972f90f06729c67e136418f62c /libbacktrace/ztest.c
parent6146ee73730cd2a4406918a0d5f98f0f71331f01 (diff)
downloadgcc-dbc31f20d30615404c2994f2d0bb9876cd75585a.zip
gcc-dbc31f20d30615404c2994f2d0bb9876cd75585a.tar.gz
gcc-dbc31f20d30615404c2994f2d0bb9876cd75585a.tar.bz2
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
Diffstat (limited to 'libbacktrace/ztest.c')
-rw-r--r--libbacktrace/ztest.c12
1 files changed, 11 insertions, 1 deletions
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 <zlib.h>
#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: