Commit dbc31f20 by Thomas Schwinge Committed by Thomas Schwinge

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
parent 6146ee73
2017-10-02 Thomas Schwinge <thomas@codesourcery.com>
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.
2017-09-29 Tony Reix <tony.reix@atos.net> 2017-09-29 Tony Reix <tony.reix@atos.net>
* xcoff.c: Initial support for DWARF debug sections in XCOFF. * xcoff.c: Initial support for DWARF debug sections in XCOFF.
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
/* Define to 1 if you have the __atomic functions */ /* Define to 1 if you have the __atomic functions */
#undef HAVE_ATOMIC_FUNCTIONS #undef HAVE_ATOMIC_FUNCTIONS
/* Define to 1 if you have the `clock_gettime' function. */
#undef HAVE_CLOCK_GETTIME
/* Define to 1 if you have the declaration of `strnlen', and to 0 if you /* Define to 1 if you have the declaration of `strnlen', and to 0 if you
don't. */ don't. */
#undef HAVE_DECL_STRNLEN #undef HAVE_DECL_STRNLEN
......
...@@ -12747,6 +12747,19 @@ $as_echo "#define HAVE_GETEXECNAME 1" >>confdefs.h ...@@ -12747,6 +12747,19 @@ $as_echo "#define HAVE_GETEXECNAME 1" >>confdefs.h
fi fi
# Check for the clock_gettime function.
for ac_func in clock_gettime
do :
ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
if test "x$ac_cv_func_clock_gettime" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_CLOCK_GETTIME 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5
$as_echo_n "checking whether -pthread is supported... " >&6; } $as_echo_n "checking whether -pthread is supported... " >&6; }
if test "${libgo_cv_lib_pthread+set}" = set; then : if test "${libgo_cv_lib_pthread+set}" = set; then :
......
...@@ -388,6 +388,9 @@ if test "$have_getexecname" = "yes"; then ...@@ -388,6 +388,9 @@ if test "$have_getexecname" = "yes"; then
AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
fi fi
# Check for the clock_gettime function.
AC_CHECK_FUNCS(clock_gettime)
dnl Test whether the compiler supports the -pthread option. dnl Test whether the compiler supports the -pthread option.
AC_CACHE_CHECK([whether -pthread is supported], AC_CACHE_CHECK([whether -pthread is supported],
[libgo_cv_lib_pthread], [libgo_cv_lib_pthread],
......
...@@ -43,6 +43,10 @@ POSSIBILITY OF SUCH DAMAGE. */ ...@@ -43,6 +43,10 @@ POSSIBILITY OF SUCH DAMAGE. */
#include <zlib.h> #include <zlib.h>
#endif #endif
#ifdef HAVE_CLOCK_GETTIME
# define TEST_TIMING
#endif
#include "backtrace.h" #include "backtrace.h"
#include "backtrace-supported.h" #include "backtrace-supported.h"
...@@ -157,7 +161,7 @@ test_samples (struct backtrace_state *state) ...@@ -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 /* Given a set of TRIALS timings, discard the lowest and highest
values and return the mean average of the rest. */ values and return the mean average of the rest. */
...@@ -216,6 +220,7 @@ test_large (struct backtrace_state *state) ...@@ -216,6 +220,7 @@ test_large (struct backtrace_state *state)
unsigned char *uncompressed_buf; unsigned char *uncompressed_buf;
size_t uncompressed_bufsize; size_t uncompressed_bufsize;
int r; int r;
# ifdef TEST_TIMING
clockid_t cid; clockid_t cid;
struct timespec ts1; struct timespec ts1;
struct timespec ts2; struct timespec ts2;
...@@ -224,6 +229,7 @@ test_large (struct backtrace_state *state) ...@@ -224,6 +229,7 @@ test_large (struct backtrace_state *state)
const size_t trials = 16; const size_t trials = 16;
size_t ctimes[16]; size_t ctimes[16];
size_t ztimes[16]; size_t ztimes[16];
# endif /* TEST_TIMING */
static const char * const names[] = { static const char * const names[] = {
"Mark.Twain-Tom.Sawyer.txt", "Mark.Twain-Tom.Sawyer.txt",
"../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt" "../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt"
...@@ -341,6 +347,8 @@ test_large (struct backtrace_state *state) ...@@ -341,6 +347,8 @@ test_large (struct backtrace_state *state)
printf ("PASS: inflate large\n"); printf ("PASS: inflate large\n");
# ifdef TEST_TIMING
for (i = 0; i < trials; ++i) for (i = 0; i < trials; ++i)
{ {
cid = CLOCK_REALTIME; cid = CLOCK_REALTIME;
...@@ -411,6 +419,8 @@ test_large (struct backtrace_state *state) ...@@ -411,6 +419,8 @@ test_large (struct backtrace_state *state)
printf ("zlib time: : %zu ns\n", ztime); printf ("zlib time: : %zu ns\n", ztime);
printf ("percentage : %g\n", (double) ztime / (double) ctime); printf ("percentage : %g\n", (double) ztime / (double) ctime);
# endif /* TEST_TIMING */
return; return;
fail: fail:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment