Ildus Kurbangaliev <i.kurbangaliev@postgrespro.ru> writes:
> I made benchmark of gettimeofday(). I believe it is certainly usable for monitoring.
> Testing configuration:
> 24 cores, Intel Xeon CPU X5675@3.07Ghz
> RAM 24 GB
> 54179703 - microseconds total
> 2147483647 - (INT_MAX), the number of gettimeofday() calls
> >>> 54179703 / 2147483647.0
> 0.025229390256679331
> Here we have the average duration of one gettimeofday in microseconds.
25 nsec per gettimeofday() is in the same ballpark as what I measured
on a new-ish machine last year:
http://www.postgresql.org/message-id/flat/31856.1400021891@sss.pgh.pa.us
The problem is that (a) on modern hardware that is not a small number,
it's the equivalent of 100 or more instructions; and (b) the results
look very much worse on less-modern hardware, particularly machines
where gettimeofday requires a kernel call.
regards, tom lane