Thread: More precise timing

  1. #1
    Registered User
    Join Date
    Jun 2006

    More precise timing

    I'm running a program on a Solaris machine and need to get more accurate timing, preferably to the 1/1000th of a second. I am currently using the clock() function which returns the time since the start of the program, which for mine is less than 1/100th usually. I have looked everywhere and can't find anything.
    Any help would be great for myself and probably 20 other people in my class. Thanks

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    maybe this helps?

    If you wouldn't mine using asm, and don't mind using proc ticks instead of seconds, you can use rdtsc, although it's a bit shakey.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    int gettimeofday(struct timeval *tv, struct timezone *tz);

    Although tv contains microsecond precision, it's accuracy is machine specific. You would need to do some local tests to find out if it was accurate enough for you.

    > I'm running a program on a Solaris machine and need to get more accurate timing
    Have you considered using the profiling tools (start with the -p or -pg compiler options)

    > you can use rdtsc
    Unless they're using solaris-x86, I don't think their processor will have this instruction.
    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. Performance Timing Function
    By rosicky2005 in forum C++ Programming
    Replies: 11
    Last Post: 05-31-2007, 03:09 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. precise timing
    By bennyandthejets in forum C Programming
    Replies: 5
    Last Post: 04-05-2003, 11:31 AM
  5. Timing in Windows
    By steinberg in forum Windows Programming
    Replies: 3
    Last Post: 07-14-2002, 12:43 AM