> For the complete documentation index, see [llms.txt](https://lados-organization.gitbook.io/goku/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lados-organization.gitbook.io/goku/chapter-19-timing-and-frame-rate-management.md).

# Chapter 19: Timing and Frame Rate Management

In this chapter, we delve into the details of managing time and frame rate in your game engine. It's critical to handle time correctly in your game, from managing frame rates to tracking elapsed time.

The `Timer` struct provides functionalities to measure the time between frames, calculate the average delta time (the time between frames), retrieve the time since the game started, get the frames per second (fps), and pause the execution of the program for a specified duration. It uses the `std::time::Instant` struct to measure time, and stores the times of the last 60 frames to calculate the average delta time and fps.

The `step` method updates the `last_frame_time` and `delta_time`, and manages the frame time history. The `get_delta`, `get_average_delta`, `get_time`, `get_micro_time`, and `get_fps` methods return the respective values. The `sleep` method pauses the execution for a specified duration.
