calculating execution time

U

Umesh

i want to calculate the time required to execute a program. Also i
want to calcute the time remaining for the execution of the program.
how can i do that?

pl mention some good websites for learning advanced C.thx.
 
I

Ian Collins

Umesh said:
i want to calculate the time required to execute a program. Also i
want to calcute the time remaining for the execution of the program.
how can i do that?
With a calculator?
 
G

Guru Jois

i want to calculate the time required to execute a program. Also i
want to calcute the time remaining for the execution of the program.
how can i do that?
In C program, read help/man page for clock(), time() and
CLOCKS_PER_SECOND

pl mention some good websites for learning advanced C.thx.

Google "advanced C guide" and follow the links.

Bye

Guru Jois
 
O

osmium

Umesh said:
i want to calculate the time required to execute a program. Also i
want to calcute the time remaining for the execution of the program.
how can i do that?

To calculate means to take some known facts, do some mathematical operations
on them and reach a numerical answer. IOW it is not the same as "measure".
Calculating execution time has always been difficult; with a modern desktop
system with virtual this and virtual that and L2 caches and advanced math
co-processors I would estimate the difficulty as somewhere between "don't
even try" and "impossible. I would doubt if there were even a handful of
people in the *world* who could do that and get a meaningful answer. And
those people work at Intel or AMD or some similar place. They are *not* the
people who used to write all these processor comparisons that used to be so
popular. I have seen good, competent people get answers that weren't even
in the ballpark. If you persist, the place to start would be an Intel site
or a site that provided the chip family you will be using.
 
C

Chris Hills

i want to calculate the time required to execute a program. Also i
want to calcute the time remaining for the execution of the program.
how can i do that?

pl mention some good websites for learning advanced C.thx.

This is usually very easy to do BUT in all cases it is going to be VERY
platform specific.

What is the target system the app will be running on and do you have an
ICE for it?
 
R

Richard Heathfield

Guru Jois said:
In C program, read help/man page for clock(), time() and
CLOCKS_PER_SECOND

Please learn C before trying to teach it. Your advice is incorrect and
unsound.
 
R

Richard

Richard Heathfield said:
Guru Jois said:


Please learn C before trying to teach it. Your advice is incorrect and
unsound.

If you know this advice to be incorrect then I guess you know the
correct answer?
 
R

Richard Heathfield

osmium said:
Calculating execution time has always been difficult; with
a modern desktop system with virtual this and virtual that and L2
caches and advanced math co-processors I would estimate the
difficulty as somewhere between "don't even try" and "impossible. I
would doubt if there were even a handful of people in the *world* who
could do that and get a meaningful answer.
And those people work at Intel or AMD or some similar place.

Well, we know they don't work at Redmond.
 
R

Richard Heathfield

Richard said:
If you know this advice to be incorrect then I guess you know the
correct answer?

It doesn't follow. For example, if someone says the population of the
planet is 1000, I know that's wrong. That doesn't mean I know the
correct figure. I just know it's a lot bigger than 1000.

Likewise, I know that you won't be able to calculate the execution time
of a program using clock(), time(), or the undefined identifier
CLOCKS_PER_SECOND. The fact that I know this doesn't imply that I have
a foolproof algorithm for calculating runtime.
 
L

Lew Pitcher

i want to calculate the time required to execute a program. Also i
want to calcute the time remaining for the execution of the program.
how can i do that?

I suggest that you google on the phrase "halting problem" and check
out a few of the references. I know that you'll find your answer
there, assuming that you recognize it.
 
C

Chris Hills

osmium said:
To calculate means to take some known facts, do some mathematical operations
on them and reach a numerical answer. IOW it is not the same as "measure".
Calculating execution time has always been difficult; with a modern desktop
system

You mean it is difficult to calculate the execution time for apps on a
modern desk top system.

I use a modern desktop system to give me cycle accurate timings. The
problem is the OP needs to supply more information, starting what the
target platform is.
with virtual this and virtual that and L2 caches and advanced math
co-processors I would estimate the difficulty as somewhere between "don't
even try" and "impossible.

For a PC app I would agree
I would doubt if there were even a handful of
people in the *world* who could do that and get a meaningful answer. And
those people work at Intel or AMD or some similar place.

They can't do it... they will have the same problems as anyone else in
the case you are suggesting. Ie an app running on a PC of unknown MCU
type and a version of Windows with other programms/dlls ec also
running.
They are *not* the
people who used to write all these processor comparisons that used to be so
popular. I have seen good, competent people get answers that weren't even
in the ballpark. If you persist, the place to start would be an Intel site
or a site that provided the chip family you will be using.

Not at all. This is quite pointless.. You have not ascertained he is
even running on x86 architecture yet!
 
C

Chris Hills

OTOH, calculating run time on an 8051, PIC, AVR, MSP430, or similiar
low-end micro is straight-forward.

Or most medium and high end MCU..... depending on if you are running no
Os, and RTOS or an OS
It is not uncommon to see documentation giving the execution time of a
routine in clock cycles, usually for code written in assembly language.

You can also time to the cycle HLL coded systems as well. I have often
don it with an ICE.

The problem we have is the vast majority on this NG have no experience
outside PC's using Windows or Linux and some will have used Unix. those
who have experience outside that narrow range seem few and far between
around here.

This was obvious when some said a map file would not contain exact
addresses of variables :- )
 
C

Chris Dollin

Chris said:
You mean it is difficult to calculate the execution time for apps on a
modern desk top system.

Was it easier on a VAX?
I use a modern desktop system to give me cycle accurate timings. The
problem is the OP needs to supply more information, starting what the
target platform is.

That's always been true, yes.

--
"It was the first really clever thing the King had said that day."
/Alice in Wonderland/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
 
T

Thad Smith

osmium said:
Calculating execution time has always been difficult; with a modern desktop
system with virtual this and virtual that and L2 caches and advanced math
co-processors I would estimate the difficulty as somewhere between "don't
even try" and "impossible. I would doubt if there were even a handful of
people in the *world* who could do that and get a meaningful answer.

OTOH, calculating run time on an 8051, PIC, AVR, MSP430, or similiar
low-end micro is straight-forward. It is not uncommon to see
documentation giving the execution time of a routine in clock cycles,
usually for code written in assembly language.
 
R

Richard

Richard Heathfield said:
Richard said:


It doesn't follow. For example, if someone says the population of the
planet is 1000, I know that's wrong. That doesn't mean I know the
correct figure. I just know it's a lot bigger than 1000.

Likewise, I know that you won't be able to calculate the execution time
of a program using clock(), time(), or the undefined identifier
CLOCKS_PER_SECOND. The fact that I know this doesn't imply that I have
a foolproof algorithm for calculating runtime.

A good point. However if you said "I know the population of the Earth is
more than 1000 because more than 1000 go to see Chelsea every saturday"
then you have justified your claim.
 
C

Chris Dollin

Chris said:
No idea but there are a hell of a Lot more platforms than a VAX and a
PC.

I don't doubt it, but it means your restriction to "modern" above is
an over-simplification.

I think the rule of thumb to use is that calculating the execution
time of (any part of) an app, given it's C source, isn't easy unless
it happens -- through some coincidence of compiler transparency and
processor simplicity -- to be easy.

One should not expect it to be easy, although if one needs to do the sums
and it /is/ easy, much joy. The details are of course atopical here.
 
C

Chris Hills

Chris Dollin said:
I don't doubt it, but it means your restriction to "modern" above is
an over-simplification.

I think the rule of thumb to use is that calculating the execution
time of (any part of) an app, given it's C source, isn't easy unless
it happens -- through some coincidence of compiler transparency and
processor simplicity -- to be easy.

Not at all. I can do it with relative ease for a PowerPC. You get the
timing not from the source code but you use a sim or an ICE on the
compiled system and can time between points be they HLL or Assembler. OR
even accesses to a memory location.

The problem only arises if you have an OS on the target that is
non-determinisitc.

Many systems run apps without an OS so their run times with and without
interrupts can be easily and repeatabley determined.

Some run with derterministic RTOS and again timings can be obtained...

Its how we do real time systems
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top