Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jan 2005 10:40:58 +0100
From:      Ulrich Spoerlein <q@uni.de>
To:        freebsd-questions@freebsd.org
Subject:   How to reliably measure user time (getrusage(2))
Message-ID:  <20050111094057.GA813@galgenberg.net>

index | next in thread | raw e-mail

Hi all,

I need to measure the time spent in user mode for rather short-lived
processes. Sadly the results vary highly

% while true;do \time -p woptsa tsplib/pla7397/pla7397.tsp 2>&1|sed -n /user/p;done
user 1.13
user 0.67
user 0.65
user 0.65
user 0.64
user 0.65
% while true;do \time -p woptsa tsplib/pla7397/pla7397.tsp 2>&1|sed -n /user/p;sleep 1;done
user 1.22
user 0.87
user 0.75
user 0.67
user 0.86
user 0.74
% while true;do \time -p woptsa tsplib/pla7397/pla7397.tsp 2>&1|sed -n /user/p;sleep 3;done
user 1.24
user 1.23
user 1.27
user 1.27
user 1.10
user 1.19

I fail to see how sleeping or waiting between consecutive runs could
affect user time. Everything from page faults to I/O is handled inside
the kernel, so it shouldn't affect user-time, no?

The only library function not taking constant time I could think of
would be malloc(3), is that a possibility?

Inside the program I'm using getrusage(2) to measure the time my program
is executing.  kern.hz is set to 1000, this is on a 5-STABLE 1.5GHz
Pentium-M. What to do?

Ulrich Spoerlein
-- 
 PGP Key ID: F0DB9F44				Encrypted mail welcome!
Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
Ok, which part of "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn."
didn't you understand?


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050111094057.GA813>