how to get the time in usec

Discussion in 'C Programming' started by JackyMove, Aug 12, 2003.

  1. JackyMove

    JackyMove Guest

    Dear all,

    I would like to get the time on how long to run a short segment of my
    c program in usec under Windows platform using dev-c++. Is there any
    method or function call to get it other than using clock()?

    Thank you very much.

    Regards,
    Jacky
     
    JackyMove, Aug 12, 2003
    #1
    1. Advertising

  2. JackyMove

    Alex Vinokur Guest

    "JackyMove" <> wrote in message news:...
    > Dear all,
    >
    > I would like to get the time on how long to run a short segment of my
    > c program in usec under Windows platform using dev-c++. Is there any
    > method or function call to get it other than using clock()?
    >
    > Thank you very much.
    >
    > Regards,
    > Jacky


    getrusage ()
    http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?getrusage
    http://www.opengroup.org/onlinepubs/007904975/functions/getrusage.html

    -------------------------------------------------------------------------------------
    http://www.hgmp.mrc.ac.uk/cgi-bin/man.cgi?section=3C&topic=getrusage
    <QUOTE>
    ru_utime The total amount of time spent executing in user
    mode. Time is given in seconds and microseconds.

    ru_stime The total amount of time spent executing in system
    mode. Time is given in seconds and microseconds.
    </QUOTE>
    -------------------------------------------------------------------------------------

    --
    =====================================
    Alex Vinokur
    mailto:
    http://mathforum.org/library/view/10978.html
    =====================================
     
    Alex Vinokur, Aug 12, 2003
    #2
    1. Advertising

  3. JackyMove

    Tim Prince Guest

    JackyMove wrote:

    > Dear all,
    >
    > I would like to get the time on how long to run a short segment of my
    > c program in usec under Windows platform using dev-c++. Is there any
    > method or function call to get it other than using clock()?
    >
    > Thank you very much.
    >
    > Regards,
    > Jacky

    clock() is the closest thing in standard C. I don't know what dev-c++ is,
    but it's surely off topic. You could count CPU clock ticks. Look up rdtsc.
    --
    Tim Prince
     
    Tim Prince, Aug 12, 2003
    #3
  4. (JackyMove) writes:
    > I would like to get the time on how long to run a short segment of my
    > c program in usec under Windows platform using dev-c++. Is there any
    > method or function call to get it other than using clock()?


    Not in standard C, but I'm sure there are Windows-specific functions
    that do what you want. Try a Windows-specific newsgroup.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
    Schroedinger does Shakespeare: "To be *and* not to be"
     
    Keith Thompson, Aug 12, 2003
    #4
  5. JackyMove

    Randy Howard Guest

    OT: Re: how to get the time in usec

    In article <DjZZa.83$>,
    says...
    > clock() is the closest thing in standard C. I don't know what dev-c++ is,
    > but it's surely off topic. You could count CPU clock ticks. Look up rdtsc.


    Unfortunately, according to Intel there is no guarantee that rdtsc will
    give you useful data on a SMP system, as the rdtsc result is not
    synchronized between CPUs. If your process gets bumped to another CPU,
    your results will be WAY off. This used to be good advice (if you didn't
    mind not being portable off of some x86 CPUs), but with SMP systems
    becoming increasingly common, it's horribly broken now. If you're using
    a broken thread implementation (I.e. one which lets you pin a thread to a
    physical CPU) then it might be useful for you, but only if the code gets
    called from a single thread. For conventional processes, forget about it.
     
    Randy Howard, Aug 15, 2003
    #5
    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. engsol
    Replies:
    2
    Views:
    995
    Dan Bishop
    Jan 26, 2004
  2. Replies:
    8
    Views:
    511
    Magnus Lycka
    Aug 5, 2005
  3. Peter Hansen
    Replies:
    0
    Views:
    735
    Peter Hansen
    Feb 22, 2006
  4. Peter Hansen
    Replies:
    0
    Views:
    630
    Peter Hansen
    Feb 22, 2006
  5. flamesrock
    Replies:
    8
    Views:
    557
    Hendrik van Rooyen
    Nov 24, 2006
Loading...

Share This Page