Thread: gettimeofday

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    2

    Question gettimeofday

    I am writing a program where i have to time how long it takes different processes. I am using the function gettimeofday which returns seconds and microseconds. I was wondering how would I turn in the result to milliseconds?

    Thanks in advance.

  2. #2
    Unregistered
    Guest

    Lightbulb

    If you can get microseconds divide it by 1000 to get milli (?)

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    There's a difference between resolution and accuracy.
    the resolution is 1uS, but the accuracy might be 20mS (ie, 50 times a second, the OS adds 20000 to the uS value).

    You need to bear this in mind if you are thinking of using it as an accurate clock.

    If you really want a fast and accurate clock, its going to be OS/compiler specific.
    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. Replies: 12
    Last Post: 02-28-2010, 06:30 AM
  2. clock vs gettimeofday
    By C_ntua in forum C Programming
    Replies: 18
    Last Post: 08-07-2008, 10:11 AM
  3. Question about Function: int gettimeofday
    By sweetorangepie in forum Linux Programming
    Replies: 8
    Last Post: 04-06-2008, 10:09 PM
  4. using clock() with sleep()
    By aleksgidenko in forum Linux Programming
    Replies: 4
    Last Post: 07-09-2007, 11:13 AM
  5. Fun with gettimeofday
    By Yasir_Malik in forum Linux Programming
    Replies: 7
    Last Post: 10-06-2003, 10:47 AM