Skip to content

getProcessCPUTime: Fix the getrusage fallback to account for system CPU time

Matthew Pickering requested to merge wip/get_r_usage into master

clock_gettime reports the combined total or user AND system time so in order to replicate it with getrusage we need to add both system and user time together.

See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime

Some sample measurements when building Cabal with this patch

t1: rusage t2: clock_gettime

t1: 62347518000; t2: 62347520873
t1: 62395687000; t2: 62395690171
t1: 62432435000; t2: 62432437313
t1: 62478489000; t2: 62478492465
t1: 62514990000; t2: 62514992534
t1: 62515479000; t2: 62515480327
t1: 62515485000; t2: 62515486344

Fixes #21656 (closed)

Edited by Matthew Pickering

Merge request reports