mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: wixor <wixorpeek@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: getrusage time measurements variations
Date: Sun, 8 Jul 2007 20:19:21 +0200	[thread overview]
Message-ID: <c43b2e150707081119h36d2fcadva5fa4ea00e68599a@mail.gmail.com> (raw)

Hello all,
I've been doing some getrusage tests using this:

#include <stdio.h>
#include <unistd.h>
#include <sys/resource.h>

int main(void)
{
    unsigned int i;
    struct rusage ru;
    for(i=1;i;i++) asm volatile("nop");
    getrusage(RUSAGE_SELF, &ru);
    printf("%dsec %dusec\n",ru.ru_utime.tv_sec,ru.ru_utime.tv_usec);
    return 0;
}

What is good is that results do not seem to depend on other thread
activity nor disk i/o. However, each time I run this program, result
varies (from 4.039 sec to 4.062 sec). Does the actual execution time
change each time? User time should not contain .so library loading
time, nor memory allocation time (kernel part) nor anything like this.
Does getrusage measure time so accurately (1usec precision), even if
HZ is set to, let's say, 100?

But that's not very bad... Problems start, when I run this with heavy
network i/o load. I'm using ne1000 network adapter (on isa bus...
well, that's very old stuff), which seem to generate interrupt on each
packet it receives - top reports very high "hi" values, up to 20%.
Results from getrusage change to 5.2 sec. Is this variation the same
one as above, but in greater scale? Can this be eliminated?

My problem is, that I'd like to measure user time of process with
1msec resolution, but what is most important, I want the result to be
the same each time I run program. Can it be done with standard linux
kernels, or should I try some "real-time" versions?

Thanks for responses, and please CC me, I'm not in the list.
--
wixor

                 reply	other threads:[~2007-07-08 18:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c43b2e150707081119h36d2fcadva5fa4ea00e68599a@mail.gmail.com \
    --to=wixorpeek@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®