Microseconds?

Monkey Forums/Monkey Programming/Microseconds?

Leo Santos(Posted 2016) [#1]
Hi,

Is there a way (module, hacked target, etc ) to get the current time in microseconds, instead of milliseconds? A Google search returned nothing. Doesn't need to work in all targets.

Turns out that a lot can happen in those 16.7 milliseconds per frame. I want to profile some things, and 1 millisecond accuracy is not enough. :-(

(On a side note, is that something Monkey 2 could do by default, since it's not limited by HTML5? Maybe returning Millisecs as a float number with microsecond accuracy?)

Cheers.


Paul - Taiphoz(Posted 2016) [#2]
Are you just trying to see how long something takes to execute, like what's faster functionA or functionB? or do you need microseconds for a game mechanic?

Not that it really matters just wondering your question sounds interesting and its got me wondering what your upto :) hope some one has an answer for you.


Leo Santos(Posted 2016) [#3]
Yup, trying to profile things so i can see exactly where the slowdowns are. I could accumulate the result over several frames, but that doesn't work very well since the error in each frame is too large. Microsecs(), or a true floating point Millisecs(), would be ideal!

I actually found a "High Resolution timer" code for html5 here:
http://www.monkey-x.com/Community/posts.php?topic=7572

But I'm a newb and have no idea about how to implement extra functions for a specific target (like, where do I even place those lines? :-P )
The docs don't seem to help in that regard.

Leo.