From: Corey Minyard <minyard@acm.org>
To: Chris Friesen <cfriesen@nortelnetworks.com>
Cc: Maciej Soltysiak <solt@dns.toxicfilms.tv>, linux-kernel@vger.kernel.org
Subject: Re: timing an application
Date: Tue, 14 Jan 2003 14:38:32 -0600 [thread overview]
Message-ID: <3E247548.1000800@acm.org> (raw)
In-Reply-To: <3E246DE5.7080302@nortelnetworks.com>
I have a patch at http://home.attbi.com/~minyard/highres-2.4.17.patch that
adds a config item that times CPU usage at microsecond resolution. It's
only
for the 2.4.17 kernel, I don't know what the porting effort would be for
other
kernels.
It's not a great patch, it would need some work to be really clean from
a code
quality point of view, but it does seem to work. With it you can use
getrusage()
to get the actual time your process has used between two points. It
works on
x86 and PPC.
Plus, obviously, this adds significant time to system calls and interrupts.
-Corey
Chris Friesen wrote:
> Maciej Soltysiak wrote:
>
>> Hi,
>>
>> being inspired by some book about optimizing c++ code i decided to do
>> timing of functions i wrote. I am using gettimeofday to set
>> two timeval structs and calculate the time between them.
>> But the results depend heavily on the load, also i reckon that this
>> is an innacurate timing.
>>
>> Any ideas on timing a function, or a block of code? Maybe some kernel
>> timers or something.
>
>
> gettimeofday() is accurate. However, your task may be interrupted by
> other tasks, interrupts, etc.
>
> Your best bet may be to do many iterations of the routine in question
> and then
> do some statistical analysis of the results.
>
> Chris
>
>
>
next prev parent reply other threads:[~2003-01-14 20:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-14 19:58 timing an application Maciej Soltysiak
2003-01-14 20:07 ` Chris Friesen
2003-01-14 20:38 ` Corey Minyard [this message]
2003-01-14 20:20 ` Richard B. Johnson
2003-01-15 12:21 ` timing an application [results] Maciej Soltysiak
2003-01-14 22:09 ` timing an application Olaf Dietsche
-- strict thread matches above, loose matches on Subject: below --
2003-01-14 20:37 Howell, David P
2003-01-14 21:34 ` David Mosberger
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=3E247548.1000800@acm.org \
--to=minyard@acm.org \
--cc=cfriesen@nortelnetworks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=solt@dns.toxicfilms.tv \
/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