From: ashekhar@luciferencore.com (Ajay Shekhar)
Subject: Re: [Q] Accurately measure exec time of a process?
Date: Tue, 6 Sep 1994 19:03:03 GMT [thread overview]
Message-ID: <Cvq295.Az6@encore.com> (raw)
In-Reply-To: 349aat$mer@pirates.cs.swt.edu
In article <349aat$mer@pirates.cs.swt.edu>, peng@pirates.cs.swt.edu (Wuxu Peng) writes:
|> I have a C program (about 2,000 lines) implementing an approximate
|> algorithm. The program has two phases. My question is: how can I
|> accurately measure the execution time of each of the two phases?
|> This measurement is important to demonstrate the usefulness of my
|> algorithm.
|>
|> Thanks in advance.
|>
|> --
|>
|> --wuxu peng (peng@pirates.cs.swt.edu)
|>
There is a macro called TIME_LOAD() which takes as input a long.
This loads the cur time in seconds and micro seconds.
You can use TIME_LOAD before and after your algorithm to measure
the difference. Something like this
#include "sys/time.h"
main()
{
long time1, time2;
...
TIME_LOAD(time1);
algorithm body
TIME_LOAD(time2);
printf("Time Difference : %d secs : %d microseconds\n",
((struct timeval *)&time2->tv_sec -
(struct timeval *)&time1->tv_sec)),
((struct timeval *)&time2->tv_usec -
(struct timeval *)&time1->tv_usec)));
You can't subtract the longs directly, because one half of the long
word contains the time in seconds and the other in microseconds.
You have to be careful with that.
Hope it helps ..
--
Ajay Shekhar
(ashekhar@encore.com)
Disclaimer : Nothing I ever say reflects Encore's opinions ...
prev parent reply other threads:[~1994-09-06 19:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-09-03 7:58 [Q] Accurately measure exec time of a process? Wuxu Peng
1994-09-03 17:45 ` Tim Hollebeek
1994-09-03 18:21 ` Arghhhhh (Was: Re: [Q] Accurately measure exec time of a process?) Matthias Blume
1994-09-04 0:00 ` [Q] Accurately measure exec time of a process? Dan Pop
1994-09-06 19:03 ` Ajay Shekhar [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox