December 22, 2024, 05:18:10

Author Topic: Measuring time?  (Read 5547 times)

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
Measuring time?
« on: September 22, 2010, 14:25:09 »
Anyone stumbled upon a reliable way to measure game time? Specifically, I need to know how much time has passed since the last frame or, alternatively, calculate the current fps and take my average frame time based on that. With a low enough tick setting, I can count the frames alright, but there doesn't seem to be a way to get the current time - and without knowing the time I only have a frame count, not a frame-per-unit-of-time value.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #1 on: September 22, 2010, 15:23:54 »
uhm.... tricky question. A tick rule and a local counter variable could do the trick, if we could somehow know if the game has been paused or not.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #2 on: September 22, 2010, 17:00:57 »
Sadly it does not suffice. Sure, you can increase a counter every Tick, but you still don't know how much time went by since the last tick. You can't rely on each Tick taking exactly the amount of time you specified in your STATE. If you set tick rate to 1, it takes roughly 1 second for each tick - but that doesn't help at all when measuring individual frame times. When working with smaller tick rates - let's say "Tick 0.001" (1ms) - then you're going to hit a wall, because the actual tick rate is always limited by the game's current fps. If you've got steady 60fps, then your ticks are going to come in roughly every 0.016 seconds - no matter how low you set the actual tick rate. In real gameplay, the framerate is going to go up and down and not be steady at all... your actual real tick rate will fluctuate very heavily and you won't have a clue just by counting the actual ticks. Without knowing how long each tick actually took, you don't know anything about fps or frame times :(

... and that's the problem I'm facing here. I need that kind of information, at least a good approximation of it - but there doesn't seem to be a good way to get the current gametime :(