From owner-freebsd-questions@FreeBSD.ORG Tue Jan 11 09:41:01 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9A5B716A4CE for ; Tue, 11 Jan 2005 09:41:01 +0000 (GMT) Received: from wrzx28.rz.uni-wuerzburg.de (wrzx28.rz.uni-wuerzburg.de [132.187.3.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id 970B543D3F for ; Tue, 11 Jan 2005 09:41:00 +0000 (GMT) (envelope-from q@uni.de) Received: from wrzx30.rz.uni-wuerzburg.de (wrzx30.rz.uni-wuerzburg.de [132.187.1.30]) by wrzx28.rz.uni-wuerzburg.de (Postfix) with ESMTP id 26AD8D7673 for ; Tue, 11 Jan 2005 10:40:59 +0100 (CET) Received: from virusscan (localhost [127.0.0.1]) by wrzx30.rz.uni-wuerzburg.de (Postfix) with ESMTP id 0EC5599756 for ; Tue, 11 Jan 2005 10:40:59 +0100 (CET) Received: from wrzx28.rz.uni-wuerzburg.de (wrzx28.rz.uni-wuerzburg.de [132.187.3.28]) by wrzx30.rz.uni-wuerzburg.de (Postfix) with ESMTP id F160B996D2 for ; Tue, 11 Jan 2005 10:40:58 +0100 (CET) Received: from coyote.q.local (wwsx14.win-screen.uni-wuerzburg.de [132.187.253.14]) by wrzx28.rz.uni-wuerzburg.de (Postfix) with ESMTP id DFA49D7673 for ; Tue, 11 Jan 2005 10:40:58 +0100 (CET) Received: from roadrunner.q.local (roadrunner.q.local [192.168.0.148]) by coyote.q.local (8.13.1/8.13.1) with ESMTP id j0B9ewJg029438 for ; Tue, 11 Jan 2005 10:40:58 +0100 (CET) (envelope-from q@uni.de) Received: from roadrunner.q.local (localhost [127.0.0.1]) by roadrunner.q.local (8.13.1/8.13.1) with ESMTP id j0B9ewTg001645 for ; Tue, 11 Jan 2005 10:40:58 +0100 (CET) (envelope-from q@uni.de) Received: (from q@localhost) by roadrunner.q.local (8.13.1/8.13.1/Submit) id j0B9ewHC001644 for freebsd-questions@freebsd.org; Tue, 11 Jan 2005 10:40:58 +0100 (CET) (envelope-from q@uni.de) Date: Tue, 11 Jan 2005 10:40:58 +0100 From: Ulrich Spoerlein To: freebsd-questions@freebsd.org Message-ID: <20050111094057.GA813@galgenberg.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new (Rechenzentrum Universitaet Wuerzburg) Subject: How to reliably measure user time (getrusage(2)) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2005 09:41:01 -0000 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?