From: Claudio Scordino <cloud.of.andor@gmail.com>
To: Ulrich Drepper <drepper@gmail.com>
Cc: linux-kernel@vger.kernel.org, fabio checconi <checconi@gandalf.sssup.it>
Subject: Re: Task profiling in Linux
Date: Tue, 1 Nov 2005 00:46:38 +0100 [thread overview]
Message-ID: <200511010046.39445.cloud.of.andor@gmail.com> (raw)
In-Reply-To: <a36005b50510310915q53ded6e8y607a536992924e5a@mail.gmail.com>
Thank you for your suggestion, but I still have a question about it.
If I do
clock_gettime (CLOCK_THREAD_CPUTIME_ID, &old);
sleep(5);
clock_gettime (CLOCK_THREAD_CPUTIME_ID, &new);
why the difference (new-old) includes also the time the process has slept ?
Maybe there was a misunderstanding: I am looking for a way to know how long a
process has _actually_ executed, accounting for all periods that it has not
executed for some reason (like sleep, blocking, preemptions, etc.). And I
need the high precision gave by the TSC (jiffies is not enough).
getrusage works fine, but has a coarse-grain precision (jiffies).
clock_gettime, instead, has a very good precision (thanks to TSC) but as you
can see, it does not return the time that the process has actually
executed...
If I am wrong, please tell me where.
Thank you,
Claudio
On Monday 31 October 2005 18:15, you wrote:
> On 10/23/05, Claudio Scordino <cloud.of.andor@gmail.com> wrote:
> > To accomplish that, I can't just read the current time in different parts
> > of the program, nor I can set and use a timer, because this wouldn't
> > consider preemptions...
>
> struct timespec start;
> clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &start);
>
> ... do work...
>
> struct timespec end;
> clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &end);
>
> ... subtract start from end
>
> Or use CLOCK_THREAD_CPUTIME_ID if this is more correct for your
> application.
>
> This works since Roland's clock work got added in the 2.6 series.
> Before that preemption wasn't excluded.
prev parent reply other threads:[~2005-10-31 23:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-23 20:49 Task profiling in Linux Claudio Scordino
2005-10-23 22:19 ` Jon Masters
2005-10-23 22:31 ` Benoit Boissinot
2005-10-24 1:21 ` Peter Chubb
[not found] ` <a36005b50510310915q53ded6e8y607a536992924e5a@mail.gmail.com>
2005-10-31 23:46 ` Claudio Scordino [this message]
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=200511010046.39445.cloud.of.andor@gmail.com \
--to=cloud.of.andor@gmail.com \
--cc=checconi@gandalf.sssup.it \
--cc=drepper@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