Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C Programming Language

calculating execution time


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.

Umesh wrote:
> 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?

--
Ian Collins.

On 5 Jun, 08:39, Ian Collins <ian-n@hotmail.com> wrote:

> Umesh wrote:
> > 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?

> --
> Ian Collins.

I think this is not far from feeding a troll...
mark_blue@pobox.com wrote:
> On 5 Jun, 08:39, Ian Collins <ian-n@hotmail.com> wrote:
>> Umesh wrote:
>>> 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?

>> --
>> Ian Collins.

> I think this is not far from feeding a troll...

It is, but it's been a quiet evening!

--
Ian Collins.

On Jun 4, 11:33 pm, Umesh <fraternitydispo@gmail.com> wrote:
> 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

On Unix box, use 'time' <command> to find how mush time the system
takes to execute it.

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

Google "advanced C guide" and follow the links.

Bye

Guru Jois

"Umesh" writes:
>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.
In article <1181025221.983441.292@o11g2000prd.googlegroups.com>,
Umesh <fraternitydispo@gmail.com> writes

>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?

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
/\/\/ c@phaedsys.org      www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Guru Jois said:

> On Jun 4, 11:33 pm, Umesh <fraternitydispo@gmail.com> wrote:
>> 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

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

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.

Richard Heathfield <r@see.sig.invalid> writes:
> Guru Jois said:

>> On Jun 4, 11:33 pm, Umesh <fraternitydispo@gmail.com> wrote:
>>> 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

> 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?
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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.

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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.

On Jun 5, 2:33 am, Umesh <fraternitydispo@gmail.com> wrote:

> 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.

osmium wrote:
> 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.

--
Thad

In article <5cksklF30ppd@mid.individual.net>, osmium
<r124c4u@comcast.net> writes

>"Umesh" writes:

>>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

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!

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
/\/\/ c@phaedsys.org      www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

In article <46655e6f$0$56919$892e0@auth.newsreader.octanews.com>,
Thad Smith <ThadSm@acm.org> writes

>osmium wrote:

>> 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.

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 :- )

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
/\/\/ c@phaedsys.org      www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

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.

Chris Hills wrote:
> 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

In article <f43p4l$8j@murdoch.hpl.hp.com>, Chris Dollin
<chris.dol@hp.com> writes

>Chris Hills wrote:

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

>Was it easier on a VAX?

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

>> 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.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
/\/\/ c@phaedsys.org      www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Chris Hills wrote:
> In article <f43p4l$8j@murdoch.hpl.hp.com>, Chris Dollin
> <chris.dol@hp.com> writes
>>Chris Hills wrote:

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

>>Was it easier on a VAX?

> 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.

--
"It is seldom good news."      ~Crystal Ball~, /The Tough Guide to Fantasyland/

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

In article <f43ruu$a9@murdoch.hpl.hp.com>, Chris Dollin
<chris.dol@hp.com> writes

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
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
/\/\/ c@phaedsys.org      www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Well, it's not a C question then, is it; it's a question about how
some (particular) C code is compiled on some (particular) platform.

> 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.

Measurement and calculation are not the same thing.

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

Or if the target itself is non-deterministic, or at least you don't
have access to the source of the apparent non-determinism: I'm
thinking vaguely of the ARM on-chip cache.

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

Sure:

>> unless
>> it happens -- through some coincidence of compiler transparency and
>> processor simplicity -- to be easy.

If you pick the situations where it's easy, it's easy.

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

> Its how we do real time systems

Yes. You do them by /arranging that it's possible/; by doing things that
aren't about C, but about the environment the code runs in and is created
by.

It's important, so you have to do it; but it's not the general case
(just as PCs and workstations aren't the general case).

--
"You've spotted a flaw in my thinking, Trev" Big Al,/The Beiderbeck Connection/

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

On Jun 5, 5:21 am, Richard Heathfield <r@see.sig.invalid> wrote:

My all advice will be specific to C on Unix which is most common. If
OS is to be discussed proir to solution,
then its better to create a saperate group for C on Windows.
 I also request you to point out where went wrong before declaring the
same.

Bye

Guru Jois

Guru Jois said:

> On Jun 5, 5:21 am, Richard Heathfield <r@see.sig.invalid> wrote:
>> Guru Jois said:

>> > On Jun 4, 11:33 pm, Umesh <fraternitydispo@gmail.com> wrote:
>> >> 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

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

> My all advice will be specific to C on Unix which is most common.

1) Here, we discuss C, not Unix.
2) Your advice is incorrect in Unix, too.

> If
> OS is to be discussed proir to solution,
> then its better to create a saperate group for C on Windows.

There *are* separate groups for discussing Unix programming and Windows
programming. Here, we discuss C.

>  I also request you to point out where went wrong before declaring the
> same.

For one thing, C has no CLOCKS_PER_SECOND identifier. For another,
neither clock() nor time() can help you to calculate run-time. The best
they can do is help you to measure it, and even then, you'd have to use
them fairly cleverly to get a good result, and you'd have to know what
sort of run-time you were trying to measure.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.

Yeah, but does that never happen?

--
clvrmnky <mailto:spamt@clevermonkey.org>

Direct replies will be blacklisted.  Replace "spamtrap" with my name to
contact me directly.

One of the legacy code bases I maintain has a logging facility that can
be enabled with an environment variable.  One of those variables will
enable prepending ticks since the last log message in front of each log
message.

We didn't care about things like CLOCKS_PER_SEC, &etc.

Probably not what the OP wants, since it is pretty rudimentary, but in
terms of helping me find places where things are slow (in shipped code
running on customer hardware) it has been invaluable.
--
clvrmnky <mailto:spamt@clevermonkey.org>

Direct replies will be blacklisted.  Replace "spamtrap" with my name to
contact me directly.

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc