linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Maciej Soltysiak <solt@dns.toxicfilms.tv>
Cc: linux-kernel@vger.kernel.org
Subject: Re: timing an application
Date: Tue, 14 Jan 2003 15:20:29 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.3.95.1030114151412.13840A-101000@chaos.analogic.com> (raw)
In-Reply-To: <Pine.LNX.4.51.0301142044400.6432@dns.toxicfilms.tv>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 978 bytes --]

On Tue, 14 Jan 2003, 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.
> 
> Regards,
> Maciej Soltysiak
> 

Easy!  Use the rdtsc instruction to obtain the number of CPU cycles
that occur between two subsequent calls. There will be some 'noise'
because of interrupt activity so make many tests, put the results
into an array, remove the slowest and the fastest, then average
the remaining data. That's good enough for "government projects".

Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.


[-- Attachment #2: Type: APPLICATION/octet-stream, Size: 7787 bytes --]

  parent reply	other threads:[~2003-01-14 20:15 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
2003-01-14 20:20 ` Richard B. Johnson [this message]
2003-01-15 12:21   ` timing an application [results] Maciej Soltysiak
2003-01-14 22:09 ` timing an application Olaf Dietsche
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=Pine.LNX.3.95.1030114151412.13840A-101000@chaos.analogic.com \
    --to=root@chaos.analogic.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;
as well as URLs for NNTP newsgroup(s).