Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Running time calculation

Reply
Thread Tools

Running time calculation

 
 
SSG
Guest
Posts: n/a
 
      07-07-2005
Hi All!

I know how to calculate the running time of a particular routine, but i
want to know how to reduce the running time in a program...........

can anyone knows help me........

also tell me the definitions for system time, user time, real
time..........

 
Reply With Quote
 
 
 
 
Lawrence Kirby
Guest
Posts: n/a
 
      07-07-2005
On Thu, 07 Jul 2005 00:15:39 -0700, SSG wrote:

> Hi All!
>
> I know how to calculate the running time of a particular routine, but i
> want to know how to reduce the running time in a program...........


This is a very large topic. You usually start however by analysing the
overall problem and selecting good algorithms. Algorithm selection can
have an enormously greater effect than micro-optimisations you might apply
later on.

> can anyone knows help me........
>
> also tell me the definitions for system time, user time, real
> time..........


These definitions don't really exist in C. You may have monitoring tools
that use these terms. A common definiion is that system time is the CPU
time spent executing in the OS/system/kernel, user time is the time spent
executing (non-system) application code and real time is the elapsed
"wall-clock" time of the execution.

In C the time() function can be used to give a measurement of real time,
and the clock() function of CPU time. the meaning of "CPU time" here is
implementation specific but it typically a combination of system and user
time, it could even correspond to real time especially on a
non-multitasking system.

Lawrence


 
Reply With Quote
 
 
 
 
Malcolm
Guest
Posts: n/a
 
      07-07-2005

"SSG" <(E-Mail Removed)> wrote
>
> I know how to calculate the running time of a particular routine, but i
> want to know how to reduce the running time in a program...........
>

Firstly reduce the big O running time of your algorithm to the minimum.

Secondly cut out as many layers of "gift-wrapping" as possible. This
includes reformatting of data and layers of indirection on top of system
calls.

Thirdly look at reducing your requirements. If you are calculating the price
of an average supermarket shop, for instance, then taking a hundred baskets
and averaging them will give you a result almost as good as trawling through
every customer for the past year.

Finally try micro-optimisation of your inner loops. For instnace you cna
rewrite in assembly to improve cache coherence.


 
Reply With Quote
 
Anonymous 7843
Guest
Posts: n/a
 
      07-07-2005
In article <dakaja$7qp$(E-Mail Removed)-infra.bt.com>,
Malcolm <(E-Mail Removed)> wrote:
>
> For instance you can rewrite in assembly to improve cache coherence.


That doesn't follow. Cache coherence is a property of the
patterns and timing of accessing objects in memory and their
mapping/unmapping from the cache. The issues involved in
tuning an algorithm to be cache-friendly apply equally whether
expressed in C or in assembly. At the very least, it's
probably a good idea to express the cache-friendly algorithm
in C first, see if it makes a difference, then go on to
assembly to extract other gains if possible.
--
7842++
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
Daylight saving time calculation mazdotnet ASP .Net 1 10-14-2006 11:11 PM
calculation of cpu idle time ram.ragu@gmail.com C Programming 33 08-29-2006 02:45 PM
time series calculation in list comprehension? falcon Python 10 03-13-2006 11:08 PM
Re: I want OPTIONAL RUNNING PRINTOUT of a series of calculation Don McDonald NZ Computing 3 07-01-2004 04:25 AM



Advertisments