X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fstrset%2Ftools%2Fspeed.c;h=8c815699012208a3ac7d3bad146a10e88c7238c9;hp=9edb0718bca17fa77b94b118e15166a907baee16;hb=c0117ccb503af9b067695441199a71db8846a296;hpb=5c559e7df1d31b4c0ddf26451fac972dc8a0c2c9 diff --git a/ccan/strset/tools/speed.c b/ccan/strset/tools/speed.c index 9edb0718..8c815699 100644 --- a/ccan/strset/tools/speed.c +++ b/ccan/strset/tools/speed.c @@ -32,23 +32,17 @@ #include /* Nanoseconds per operation */ -static size_t normalize(const struct timeval *start, - const struct timeval *stop, +static size_t normalize(const struct timespec *start, + const struct timespec *stop, unsigned int num) { - struct timeval diff; - - timersub(stop, start, &diff); - - /* Floating point is more accurate here. */ - return (double)(diff.tv_sec * 1000000 + diff.tv_usec) - / num * 1000; + return time_to_nsec(time_divide(time_sub(*stop, *start), num)); } int main(int argc, char *argv[]) { size_t i, j, num; - struct timeval start, stop; + struct timespec start, stop; struct strset set; char **words, **misswords;