Thread: C timing routines

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    5

    C timing routines

    I am a bit baffled that the time functions in C seem to only be accurate to the nearest second. This is apart from the clock() function which measures processor time. However, this is not much good to me as I am trying to time work which is being loaded onto a coprocessor. Is there any more accurate functions for measuring elapsed time?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    That depends on your Processor/OS/Compiler
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    Look for sys/timeb.h in your include path.

    If it's there, find out about ftime().

    Dave

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    5
    Processor: Pentium 4
    O/S: Linux (Redhat)
    Compiler Intel (icc) - could also use gnu or portland group.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Check my use of rdtsc here
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Counter (Time)
    By PickleBranston in forum C Programming
    Replies: 16
    Last Post: 02-10-2009, 01:00 PM
  2. My Timing System
    By jmd15 in forum Windows Programming
    Replies: 4
    Last Post: 01-01-2006, 11:43 PM
  3. Games - timing
    By Magos in forum Game Programming
    Replies: 7
    Last Post: 03-06-2004, 11:32 AM
  4. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-20-2002, 11:35 PM
  5. rom/bios routines
    By ALLRIGHT in forum C Programming
    Replies: 1
    Last Post: 05-12-2002, 11:38 AM