* [Q] Accurately measure exec time of a process?
@ 1994-09-03 7:58 Wuxu Peng
1994-09-03 17:45 ` Tim Hollebeek
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wuxu Peng @ 1994-09-03 7:58 UTC (permalink / raw)
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)
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Q] Accurately measure exec time of a process?
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
2 siblings, 1 reply; 5+ messages in thread
From: Tim Hollebeek @ 1994-09-03 17:45 UTC (permalink / raw)
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.
>
find and learn how to use a prof or gprof. It will give you execution
times for every function in your C program. In your case you would
just have to make sure your program looks something like:
void main() {
doTaskOne();
doTaskTwo();
}
i.e. a subroutine for each phase
^ permalink raw reply [flat|nested] 5+ messages in thread* Arghhhhh (Was: Re: [Q] Accurately measure exec time of a process?)
1994-09-03 17:45 ` Tim Hollebeek
@ 1994-09-03 18:21 ` Matthias Blume
0 siblings, 0 replies; 5+ messages in thread
From: Matthias Blume @ 1994-09-03 18:21 UTC (permalink / raw)
In article <1994Sep3.174554.27974@Princeton.EDU> tim@handel.Princeton.EDU (Tim Hollebeek) writes:
[ ... ] In your case you would
just have to make sure your program looks something like:
void main() {
doTaskOne();
doTaskTwo();
}
no, No, NO, *NO*, NOOOOOOOOOO!!!!
(See the numerous threads on how to correctly declare ``main''. I'm
sick of it.)
Maybe someone can set up an automated service which sends a followup
to each and every article in c.l.c (excluding its own) -- with the
portion of the FAQ, quotes from the standard, K&R2, H&S, etc., and a
standard flame -- all concerning the correct definition of ``main'',
and why ``void main ...'' is wrong. There is an 80% chance that this
kind of followup is appropriate.
--
-Matthias
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Q] Accurately measure exec time of a process?
1994-09-03 7:58 [Q] Accurately measure exec time of a process? Wuxu Peng
1994-09-03 17:45 ` Tim Hollebeek
@ 1994-09-04 0:00 ` Dan Pop
1994-09-06 19:03 ` Ajay Shekhar
2 siblings, 0 replies; 5+ messages in thread
From: Dan Pop @ 1994-09-04 0:00 UTC (permalink / raw)
In <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.
>
man 3 clock
Dan
--
Dan Pop
CERN, CN Division
Email: danpop@cernapo.cern.ch
Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Q] Accurately measure exec time of a process?
1994-09-03 7:58 [Q] Accurately measure exec time of a process? Wuxu Peng
1994-09-03 17:45 ` Tim Hollebeek
1994-09-04 0:00 ` [Q] Accurately measure exec time of a process? Dan Pop
@ 1994-09-06 19:03 ` Ajay Shekhar
2 siblings, 0 replies; 5+ messages in thread
From: Ajay Shekhar @ 1994-09-06 19:03 UTC (permalink / raw)
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 ...
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1994-09-06 19:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox