mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-26 09:07:38 +01:00
(gettime): Go back to gettimeofday(). clock_gettime() requires
librt which requires libpthread, which slows everything down. (Logical change 1.197)
This commit is contained in:
parent
69052ef3ea
commit
e3eae74698
1 changed files with 9 additions and 4 deletions
|
@ -48,10 +48,10 @@ static char big[64*MB]; /* should be >> max. cache size */
|
||||||
static inline double
|
static inline double
|
||||||
gettime (void)
|
gettime (void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timeval tv;
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
gettimeofday (&tv, NULL);
|
||||||
return ts.tv_sec + 1e-9*ts.tv_nsec;
|
return tv.tv_sec + 1e-6*tv.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -137,7 +137,7 @@ static void
|
||||||
measure_init (void)
|
measure_init (void)
|
||||||
{
|
{
|
||||||
# define N 100
|
# define N 100
|
||||||
# define M 10 /* must be at least 2 to get steady-state */
|
# define M 1000000 /* must be at least 2 to get steady-state */
|
||||||
double stop, start, get_cold, get_warm, init_cold, init_warm, delta;
|
double stop, start, get_cold, get_warm, init_cold, init_warm, delta;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -153,6 +153,7 @@ measure_init (void)
|
||||||
uc[N];
|
uc[N];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* Run each test M times and take the minimum to filter out noise
|
/* Run each test M times and take the minimum to filter out noise
|
||||||
such dynamic linker resolving overhead, context-switches,
|
such dynamic linker resolving overhead, context-switches,
|
||||||
page-in, cache, and TLB effects. */
|
page-in, cache, and TLB effects. */
|
||||||
|
@ -198,6 +199,9 @@ measure_init (void)
|
||||||
if (delta < get_warm)
|
if (delta < get_warm)
|
||||||
get_warm = delta;
|
get_warm = delta;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
unw_getcontext (&uc[0].uc);
|
||||||
|
#endif
|
||||||
|
|
||||||
init_warm = 1e99;
|
init_warm = 1e99;
|
||||||
for (j = 0; j < M; ++j)
|
for (j = 0; j < M; ++j)
|
||||||
|
@ -215,6 +219,7 @@ measure_init (void)
|
||||||
1e9 * get_cold, 1e9 * get_warm);
|
1e9 * get_cold, 1e9 * get_warm);
|
||||||
printf ("unw_init_local : cold avg=%9.3f nsec, warm avg=%9.3f nsec\n",
|
printf ("unw_init_local : cold avg=%9.3f nsec, warm avg=%9.3f nsec\n",
|
||||||
1e9 * init_cold, 1e9 * init_warm);
|
1e9 * init_cold, 1e9 * init_warm);
|
||||||
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue