Performance Information#

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 – The width of the chart texture in pixels

  • height – The height of the chart texture in pixels

  • graph_data – The pyglet event handler or statistic to track

  • update_rate – How often the graph updates, in seconds

  • background_color – The background color of the chart

  • data_line_color – Color of the line tracking drawn

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

  • font_color – The color of the label font

  • font_size – The size of the label font in points

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

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

remove_from_sprite_lists()[source]#

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

Returns:

update_graph(delta_time: float)[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.

axis_color#
background_color#
boundary_bottom: float | None#
boundary_left: float | None#
boundary_right: float | None#
boundary_top: float | None#
change_angle: float#
cur_texture_index: int#
font_color#
font_size#
force#
grid_color#
guid: str | None#
physics_engines: List[Any]#
textures: List[Texture]#
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.disable_timings() None[source]#

Disable collection of timing information.

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

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.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.get_timings() Dict[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.print_timings()[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.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.