Commit c0117ccb authored by Rusty Russell's avatar Rusty Russell

strset: update ccan/time usage in tools

Broken since commit 2012d45e
which switched to timespec.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent beb01ef8
...@@ -381,23 +381,17 @@ return allprefixed_traverse(top,handle,arg); ...@@ -381,23 +381,17 @@ return allprefixed_traverse(top,handle,arg);
/* end critbit */ /* end critbit */
/* Nanoseconds per operation */ /* Nanoseconds per operation */
static size_t normalize(const struct timeval *start, static size_t normalize(const struct timespec *start,
const struct timeval *stop, const struct timespec *stop,
unsigned int num) unsigned int num)
{ {
struct timeval diff; return time_to_nsec(time_divide(time_sub(*stop, *start), num));
timersub(stop, start, &diff);
/* Floating point is more accurate here. */
return (double)(diff.tv_sec * 1000000 + diff.tv_usec)
/ num * 1000;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
size_t i, j, num; size_t i, j, num;
struct timeval start, stop; struct timespec start, stop;
critbit0_tree ct; critbit0_tree ct;
char **words, **misswords; char **words, **misswords;
......
...@@ -32,23 +32,17 @@ ...@@ -32,23 +32,17 @@
#include <sys/time.h> #include <sys/time.h>
/* Nanoseconds per operation */ /* Nanoseconds per operation */
static size_t normalize(const struct timeval *start, static size_t normalize(const struct timespec *start,
const struct timeval *stop, const struct timespec *stop,
unsigned int num) unsigned int num)
{ {
struct timeval diff; return time_to_nsec(time_divide(time_sub(*stop, *start), num));
timersub(stop, start, &diff);
/* Floating point is more accurate here. */
return (double)(diff.tv_sec * 1000000 + diff.tv_usec)
/ num * 1000;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
size_t i, j, num; size_t i, j, num;
struct timeval start, stop; struct timespec start, stop;
struct strset set; struct strset set;
char **words, **misswords; char **words, **misswords;
......
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