# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lados-organization.gitbook.io/goku/chapter-19-timing-and-frame-rate-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
