Running time calculation

Discussion in 'C Programming' started by SSG, Jul 7, 2005.

  1. SSG

    SSG Guest

    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..........
     
    SSG, Jul 7, 2005
    #1
    1. Advertising

  2. 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
     
    Lawrence Kirby, Jul 7, 2005
    #2
    1. Advertising

  3. SSG

    Malcolm Guest

    "SSG" <> 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.
     
    Malcolm, Jul 7, 2005
    #3
  4. In article <dakaja$7qp$-infra.bt.com>,
    Malcolm <> 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++
     
    Anonymous 7843, Jul 7, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. falcon
    Replies:
    10
    Views:
    577
    falcon
    Mar 13, 2006
  2. mazdotnet

    Daylight saving time calculation

    mazdotnet, Oct 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    330
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Oct 15, 2006
  3. flamesrock
    Replies:
    8
    Views:
    502
    Hendrik van Rooyen
    Nov 24, 2006
  4. calculation of cpu idle time

    , Aug 23, 2006, in forum: C Programming
    Replies:
    33
    Views:
    1,022
    jmcgill
    Aug 29, 2006
  5. calculation of cpu idle time

    , Aug 23, 2006, in forum: C Programming
    Replies:
    2
    Views:
    722
    Flash Gordon
    Aug 23, 2006
Loading...

Share This Page