[Solved] Accurate time tracking [solution: use Time("timestamp")]

I’m trying to measure the time taken by my code. In order to do it I’m using a text element which displays a timer.

Since timers are affected by processor speed, and since the code I’m testing is very slow, the timer says 1.6s when the actual time passed is 5s. How can I fix it?

  • maybe there’s an internal feature I’m missing?
  • maybe by accessing the device’s clock?

I’m aware there are tools like the debugger and the profiler, but I have to measure the performances on multiple devices. (I can’t ask my friends to install and learn Gdevelop to tell me if my game lags :stuck_out_tongue:)

You have a few options, you could try using TimeDelta() to do your own calculations, but even that may be impacted by CPU speed. You could also use Time(timestamp) to get the system timestamp and compare between before/after.

1 Like

@Silver-Streak Thanks, that’s what I’ve done.

Memo: it’s Time(“timestamp”) (Gdevelop has a way of telling that you must quote it, but only in some places, it took me 3 minutes to find the problem)

1 Like