From owner-freebsd-questions Sun Nov 22 18:23:21 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA12844 for freebsd-questions-outgoing; Sun, 22 Nov 1998 18:23:21 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from mail4.aracnet.com (mail4.aracnet.com [205.159.88.46]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA12839 for ; Sun, 22 Nov 1998 18:23:18 -0800 (PST) (envelope-from ben@ben.com) Received: from pulsar.ben.com (max1-24.cust.aracnet.com [216.99.197.24]) by mail4.aracnet.com (8.9.1/8.9.0) with ESMTP id SAA17779 for ; Sun, 22 Nov 1998 18:22:43 -0800 Received: from localhost (localhost [127.0.0.1]) by pulsar.ben.com (8.8.8/8.6.12) with SMTP id SAA08999 for ; Sun, 22 Nov 1998 18:24:09 -0800 (PST) Message-Id: <199811230224.SAA08999@pulsar.ben.com> To: freebsd-questions@FreeBSD.ORG Subject: why does getrusage ru_utime jump backwards sometimes? Date: Sun, 22 Nov 1998 18:24:09 -0800 From: Ben Jackson Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I'm trying to use getrusage(RUSAGE_SELF) to measure how much CPU time something is taking (no, I can't use regular profiling for this). I'm running into a problem with occasional *negative* deltas between two calls to getrusage. The following program illustrates it: #include #include main() { struct rusage ru; while (1) { getrusage(RUSAGE_SELF, &ru); printf("%d %d\n", ru.ru_utime.tv_sec, ru.ru_utime.tv_usec); } } If you run this (and pipe to uniq to cut the output a bit) you'll see places where the ru.utime.tv_usec goes backwards... Here's an example: 0 14090 0 14092 0 14094 0 14096 0 14098 0 14100 0 11283 0 11285 0 11286 0 11288 0 11290 0 11291 0 11293 0 11294 so each call normally goes up 2us, but sometimes jumps back 3ms! This happens on my PII 350 and my P120. My system info: FreeBSD pulsar.ben.com 2.2.7-RELEASE FreeBSD 2.2.7-RELEASE #0: Sun Sep 13 04:49:04 PDT 1998 bjj@pulsar.ben.com:/usr/src/sys/compile/PULSAR i386 --Ben To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message