Re: [Qemu-devel] [PATCH v1 02/26] qemu-io-cmds: use clock_gettime for benchmarking

2019-05-30 Thread Richard Henderson
On 5/30/19 5:15 AM, Alex Bennée wrote: > -static struct timeval tsub(struct timeval t1, struct timeval t2) > +static struct timespec tsub(struct timespec t1, struct timespec t2) > { > -t1.tv_usec -= t2.tv_usec; > -if (t1.tv_usec < 0) { > -t1.tv_usec += 100; > +t1.tv_nsec -=

[Qemu-devel] [PATCH v1 02/26] qemu-io-cmds: use clock_gettime for benchmarking

2019-05-30 Thread Alex Bennée
The previous use of gettimeofday() ran into undefined behaviour when we ended up doing a div 0 for a very short operation. This is because gettimeofday only works at the microsecond level as well as being prone to discontinuous jumps in system time. Using clock_gettime with CLOCK_MONOTONIC gives gr