Search Unity

Job friendly Stopwatch?

Discussion in 'Entity Component System' started by drhodor, Apr 16, 2019.

  1. drhodor

    drhodor

    Joined:
    Aug 18, 2013
    Posts:
    39
    What's the best way to get a job friendly stopwatch going? I don't want to send millis in, that doesn't make any sense for a job that is going to be scheduled at an undetermined time in the future ;)
     
  2. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    What do you want to archive?
     
  3. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    You either have to send the millis in, or read the current time every frame. your stopwatch can't work if it does not keep track of time
     
  4. drhodor

    drhodor

    Joined:
    Aug 18, 2013
    Posts:
    39
    @Spy-Shifty jobified networking rtt computation, among other things
     
  5. drhodor

    drhodor

    Joined:
    Aug 18, 2013
    Posts:
    39
    Exactly -- that does not suffice.
     
  6. krzysie7

    krzysie7

    Joined:
    Jan 4, 2019
    Posts:
    6
    You could have a look at how Stopwatch is implemented, on Win32 it is calling QueryPerformanceCounter() from kernel32.dll (don't know about other platfroms), my guess is it works fine in a job, and newer versions of Burst even allow DllImport if i'm not mistaken, so this could work.
     
    drhodor likes this.