Performance Information

arcade.print_timings() None[source]

Print event handler statistics to stdout as a table.

Performance tracking must be enabled with arcade.enable_timings() before calling this function.

See Performance Statistics for an example of how to use function.

The statistics consist of:

  • how many times each registered event was called

  • the average time for handling each type of event in seconds

The table looks something like:

Event          Count Average Time
-------------- ----- ------------
on_update         60       0.0000
on_mouse_enter     1       0.0000
on_mouse_motion   39       0.0000
on_expose          1       0.0000
on_draw           60       0.0020
arcade.clear_timings() None[source]

Reset the count & average time for each event type to zero.

Performance tracking must be enabled with arcade.enable_timings() before calling this function.

See Performance Statistics for an example of how to use function.

arcade.get_timings() dict[str, deque[float]][source]

Get a dict of the current dispatch event timings.

Performance tracking must be enabled with arcade.enable_timings() before calling this function.

Returns:

A dict of event timing data, consisting of counts and average handler duration.

arcade.enable_timings(max_history: int = 100) None[source]

Enable recording of performance information.

This function must be called before using any other performance features, except for arcade.timings_enabled(), which can be called at any time.

See Performance Statistics for an example of how to use function.

Parameters:

max_history – How many frames to keep performance info for.

arcade.disable_timings() None[source]

Disable collection of timing information.

Performance tracking must be enabled with arcade.enable_timings() before calling this function.

arcade.get_fps(frame_count: int = 60) float[source]

Get the FPS over the last frame_count frames.

Performance tracking must be enabled with arcade.enable_timings() before calling this function.

To get the FPS over the last 30 frames, you would pass 30 instead of the default 60.

See Performance Statistics for an example of how to use function.

Parameters:

frame_count – How many frames to calculate the FPS over.

arcade.timings_enabled() bool[source]

Return true if timings are enabled, false otherwise.

This function can be used at any time to check if timings are enabled. See arcade.enable_timings() for more information.

Returns:

Whether timings are currently enabled.

class arcade.PerfGraph(width: int, height: int, graph_data: str = 'FPS', update_rate: float = 0.1, background_color: tuple[int, int, int, int] = (0, 0, 0, 255), data_line_color: tuple[int, int, int, int] = (255, 255, 255, 255), axis_color: tuple[int, int, int, int] = (155, 135, 12, 255), grid_color: tuple[int, int, int, int] = (155, 135, 12, 255), font_color: tuple[int, int, int, int] = (255, 255, 255, 255), font_size: int = 10, y_axis_num_lines: int = 4, view_y_scale_step: float = 20.0)[source]

Bases: Sprite

An auto-updating line chart of FPS or event handler execution times.

You must use arcade.enable_timings() to turn on performance tracking for the chart to display data.

Aside from instantiation and updating the chart, this class behaves like other arcade.Sprite instances. You can use it with SpriteList normally. See Performance Statistics for an example of how to use this class.

Unlike other Sprite instances, this class neither loads an arcade.Texture nor accepts one as a constructor argument. Instead, it creates a new internal Texture instance. The chart is automatically redrawn to this internal Texture every update_rate seconds.

Parameters:
  • width (int) – The width of the chart texture in pixels

  • height (int) – The height of the chart texture in pixels

  • graph_data (str) – The pyglet event handler or statistic to track

  • update_rate (float) – How often the graph updates, in seconds

  • background_color (RGBA255) – The background color of the chart

  • data_line_color (RGBA255) – Color of the line tracking drawn

  • axis_color (RGBA255) – The color to draw the x & y axes in

  • font_color (RGBA255) – The color of the label font

  • font_size (int) – The size of the label font in points

  • y_axis_num_lines (int) – How many grid lines should be used to divide the y scale of the graph.

  • view_y_scale_step (float) – The graph’s view area will be scaled to a multiple of this value to fit to the data currently displayed.

property axis_color: Color

Get or set the color of the x and y axes.

property background_color: Color

Get or set the background color of the graph.

boundary_bottom: float | None

PhysicsEnginePlatformer uses this as the top boundary for moving platforms.

boundary_left: float | None

PhysicsEnginePlatformer uses this as the left boundary for moving platforms.

boundary_right: float | None

PhysicsEnginePlatformer uses this as the right boundary for moving platforms.

boundary_top: float | None

PhysicsEnginePlatformer uses this as the top boundary for moving platforms.

change_angle: float

Change in angle per 1/60th of a second.

cur_texture_index: int

Current texture index for sprite animation.

property font_color: Color

Get or set the font color of the labels.

property font_size: int

Get or set the font size of the labels.

force

force vector used by pymunk

graph_data

The graphed data type, either “FPS” or a pyglet event handler name.

property grid_color: Color

Get or set the color of the grid lines.

guid: str | None

A unique id for debugging purposes.

line_color

The color of the line tracking the data.

physics_engines: list[Any]

List of physics engines that have registered this sprite.

remove_from_sprite_lists() None[source]

Remove the sprite from all lists and cancel the update event.

textures: list[Texture]

List of textures stored in the sprite.

update_graph(delta_time: float) None[source]

Update the graph by redrawing the internal texture data.

Warning

You do not need to call this method! It will be called automatically!

Parameters:

delta_time – Elapsed time in seconds. Passed by the pyglet scheduler.