Skip to content

Latest commit

 

History

History
82 lines (44 loc) · 2.11 KB

benchmark.md

File metadata and controls

82 lines (44 loc) · 2.11 KB

Benchmark

from tdw.add_ons.benchmark import Benchmark

Benchmark the frames per second (FPS) over a given number of frames.


Fields

  • times A list of time elapsed per communicate() call.

  • fps The frames per second of the previous benchmark test.

  • commands These commands will be appended to the commands of the next communicate() call.

  • initialized If True, this module has been initialized.


Functions

__init__

Benchmark()

(no parameters)

get_initialization_commands

self.get_initialization_commands()

This function gets called exactly once per add-on. To re-initialize, set self.initialized = False.

Returns: A list of commands that will initialize this add-on.

on_send

self.on_send(resp)

This is called after commands are sent to the build and a response is received.

Use this function to send commands to the build on the next frame, given the resp response. Any commands in the self.commands list will be sent on the next frame.

Parameter Type Default Description
resp List[bytes] The response from the build.

before_send

self.before_send(commands)

Update the time.

Parameter Type Default Description
commands List[dict] The commands that are about to be sent to the build.

get_early_initialization_commands

self.get_early_initialization_commands()

This function gets called exactly once per add-on. To re-initialize, set self.initialized = False.

These commands are added to the list being sent on communicate() before any other commands, including those added by the user and by other add-ons.

Usually, you shouldn't override this function. It is useful for a small number of add-ons, such as loading screens, which should initialize before anything else.

Returns: A list of commands that will initialize this add-on.

start

self.start()

Start benchmarking each communicate() call and clear self.times.

stop

self.stop()

Stop benchmarking each communicate() call and set self.fps.