C timing routines

This is a discussion on C timing routines within the C Programming forums, part of the General Programming Boards category; I am a bit baffled that the time functions in C seem to only be accurate to the nearest second. ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 12:00 PM
  2. My Timing System
    By jmd15 in forum Windows Programming
    Replies: 4
    Last Post: 01-01-2006, 10:43 PM
  3. Games - timing
    By Magos in forum Game Programming
    Replies: 7
    Last Post: 03-06-2004, 10: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21