More precise timing

This is a discussion on More precise timing within the C++ Programming forums, part of the General Programming Boards category; I'm running a program on a Solaris machine and need to get more accurate timing, preferably to the 1/1000th of ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    1

    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
    Posts
    594
    maybe this helps?
    http://www.opensolaris.org/os/articl...amming/#timers

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,671
    Try
    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.
    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. 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, 10:43 PM
  3. Games - timing
    By Magos in forum Game Programming
    Replies: 7
    Last Post: 03-06-2004, 10:32 AM
  4. precise timing
    By bennyandthejets in forum C Programming
    Replies: 5
    Last Post: 04-05-2003, 10:31 AM
  5. Timing in Windows
    By steinberg in forum Windows Programming
    Replies: 3
    Last Post: 07-14-2002, 12:43 AM

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