getting current timestamp in micro secs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ashit Vora

    getting current timestamp in micro secs

    Hi,
    I want to find the current time stamp in micro sec precision.

    The requirement is,
    my function is executed in an infinite loop.
    I measure a value and check if the value computed is what i expected
    9forget all this stuff).
    I want to print the time stamp every time that event occurs.

    So my requirement is printing the current timestamps.

    so I can calculate the average time (in micro secs) after which such
    an event occur...

    I hope I made my requirement clear.

    Can anybody pls help me with this problem.
    I searched many discussion but couldn't find satisfactory answer.

    thanks in advance
  • Erik Trulsson

    #2
    Re: getting current timestamp in micro secs

    Ashit Vora <a.k.vora@gmail .comwrote:
    Hi,
    I want to find the current time stamp in micro sec precision.
    >
    The requirement is,
    my function is executed in an infinite loop.
    I measure a value and check if the value computed is what i expected
    9forget all this stuff).
    I want to print the time stamp every time that event occurs.
    >
    So my requirement is printing the current timestamps.
    >
    so I can calculate the average time (in micro secs) after which such
    an event occur...
    >
    I hope I made my requirement clear.
    >
    Can anybody pls help me with this problem.
    I searched many discussion but couldn't find satisfactory answer.
    >
    thanks in advance
    There is no portable way of doing that, so you will have to use some
    system-specific method to do it.
    If you are using some Unix-like system, then you will probably have
    gettimeofday() available. Beware though that even if it does return a value
    in microseconds it will on, most systems, not be accurate to more than 10ms
    or so.

    If you actually need microsecond precision then whatever method you may
    find, will be highly specific to your particular system and not at all
    portable.






    --
    <Insert your favourite quote here.>
    Erik Trulsson
    ertr1013@studen t.uu.se

    Comment

    • Nick Keighley

      #3
      Re: getting current timestamp in micro secs

      On 18 Sep, 07:35, Ashit Vora <a.k.v...@gmail .comwrote:
      I want to find the current time stamp in micro sec precision.
      >
      The requirement is,
      my function is executed in an infinite loop.
      I measure a value and check if the value computed is what i expected
      9forget all this stuff).
      I want to print the time stamp every time that event occurs.
      >
      So my requirement is printing the current timestamps.
      >
      so I can calculate the average time (in micro secs) after which such
      an event occur...
      >
      I hope I made my requirement clear.
      >
      Can anybody pls help me with this problem.
      I searched many discussion but couldn't find satisfactory answer.
      >
      thanks in advance
      you've already been told the answer to this.
      Why did you post again?

      --
      Nick Keighley

      Comment

      Working...