K
kavi
Hello friends,
Could any one tell the way of calculating the speed of c program
execution?
Could any one tell the way of calculating the speed of c program
execution?
Time it?kavi said:Hello friends,
Could any one tell the way of calculating the speed of c program
execution?
Time it?
Richard said:Ian Collins said:
That only tells you the time of execution. To calculate the speed, you will
also need to know the distance the program travels within that time.
Richard Heathfield said:Ian Collins said:
That only tells you the time of execution. To calculate the speed, you will
also need to know the distance the program travels within that time.
David Wade said:Is that why mainframes are faster then? As they are physically bigger the
program bytes have further to travel from the RAM to the CPU so they must
travel at a higher speed?
Is it Friday afternoon again? That came round quickly
kavi said:Hello friends,
Could any one tell the way of calculating the speed of c program
execution?
The clock function in <time.h> is for timing programs
or parts of programs.
{
clock_t start, stop;
start = clock();
while (start == clock()) {
;
}
start = clock();
/*
** Timed event goes here
*/
stop = clock();
return (double)(stop - start) / (double)CLOCKS_PER_SEC;
kavi said:Could any one tell the way of calculating the speed of c program
execution?
pete said:kavi said:Hello friends,
Could any one tell the way of calculating the speed of c program
execution?
The clock function in <time.h> is for timing programs
or parts of programs.
{
clock_t start, stop;
start = clock();
while (start == clock()) {
;
}
start = clock();
/*
** Timed event goes here
*/
stop = clock();
return (double)(stop - start) / (double)CLOCKS_PER_SEC;
}
7.23.2.1 The clock function
Synopsis
[#1]
#include <time.h>
clock_t clock(void);
Description
[#2] The clock function determines the processor time used.
Returns
[#3] The clock function returns the implementation's best
approximation to the processor time used by the program
since the beginning of an implementation-defined era related
only to the program invocation. To determine the time in
seconds, the value returned by the clock function should be
divided by the value of the macro CLOCKS_PER_SEC. If the
processor time used is not available or its value cannot be
represented, the function returns the value clock_t)-1.252)
____________________
252In order to measure the time spent in a program, the
clock function should be called at the start of the
program and its return value subtracted from the value
returned by subsequent calls.
where CLOCKS_PER_SEC equals 1000000 this function will return theFrom my man: "Note that the time can wrap around. On a 32 bit system
Your second post only makes sense to people using the Google Bulletin Board,
it is nonsense to the general Usenet population.
Nelu said:kavi said:Hello friends,
Could any one tell the way of calculating the speed of c program
execution?
The clock function in <time.h> is for timing programs
or parts of programs.
{
clock_t start, stop;
start = clock();
while (start == clock()) {
;
}
start = clock();
/*
** Timed event goes here
*/
stop = clock();
return (double)(stop - start) / (double)CLOCKS_PER_SEC;
}
7.23.2.1 The clock function
Synopsis
[#1]
#include <time.h>
clock_t clock(void);
Description
[#2] The clock function determines the processor time used.
Returns
[#3] The clock function returns the implementation's best
approximation to the processor time used by the program
since the beginning of an implementation-defined era related
only to the program invocation. To determine the time in
seconds, the value returned by the clock function should be
divided by the value of the macro CLOCKS_PER_SEC. If the
processor time used is not available or its value cannot be
represented, the function returns the value clock_t)-1.252)
____________________
252In order to measure the time spent in a program, the
clock function should be called at the start of the
program and its return value subtracted from the value
returned by subsequent calls.where CLOCKS_PER_SEC equals 1000000 this function will return theFrom my man: "Note that the time can wrap around. On a 32 bit system
same value approximately every 72 minutes".
If this is the case, I hope his program doesn't need 72 minutes to
complete.
In that case he's better off using a stop watch .
Is clock affected by other processes in a multitasking OS, or does it
count only when the CPU works on the calling process?
kwikius said:Unless the app is so fast that it distorts space time . Once the speed
of light itself is approached however, buffer overruns cannot occur.
Running the app at a high temperature has also been shown to increase
performance in some cases.
regards
Andy Little
kavi said:Hello friends,
Could any one tell the way of calculating the speed of c program
execution?
.... whatever is more appropriate .pete said:... or maybe even a calendar.
That's why I asked, because it can be difficult to time in a"the implementation's best approximation
to the processor time used by the program"
... which means
"only when the CPU works on the calling process"
except that
"other processes in a multitasking OS"
make the timing more complicated and possibly less accurate.
Richard said:While it is indeed good policy to quote that to which one is
responding, it is not the case that it only makes sense to people
using the Google Bulletin Board. Many usenet readers use news
readers that are threaded - I've been reading usenet for 24 years
and I've never used one that wasn't.
Although propagation times do vary and it can happen that a
response arrives before the original, it is unusual and the delay
is usually minor.
In short, your comment was an overstatement.
kavi said:Hello friends,
Could any one tell the way of calculating the speed of c program
execution?
Richard Harter said:While it is indeed good policy to quote that to which one is
responding, it is not the case that it only makes sense to people
using the Google Bulletin Board. Many usenet readers use news readers
that are threaded - I've been reading usenet for 24 years and I've
never used one that wasn't.
Although propagation times do vary and it can happen that a response
arrives before the original, it is unusual and the delay is usually
minor.
In short, your comment was an overstatement.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.