All options can be accessed and modified on Optimizer.options.
Optional
_options: Partial<OptimizerOptions>The timestamp indicating when the optimization process begins. Represented as the number of milliseconds elapsed since the UNIX epoch.
Whether or not the optimizer has stopped iterating and sampling the framerate.
The current optimization level or state. This value represents the current stage or level of optimization being applied.
The current priority level of the optimizer. This can be a number representing the priority or null if no priority is set.
The number of frames that have elapsed since the start of the optimization process.
The amount of time that has elapsed, in milliseconds.
The minimum priority level for the optimizer. This value determines the lowest priority task that the optimizer will consider.
A dictionary where the key is a number representing an optimization level
and the value is an array of Optimization
objects associated with that level.
See OptimizerOptions for more information.
The number of frames that have been waited. This property keeps track of how many frames have passed while waiting for a certain condition or event.
The number of milliseconds that the optimizer has waited. This value is used to track the waiting time for certain operations.
Getter and setter for enabling or disabling the optimizer. Elapsed time is reset on reenable.
Getter and setter for enabling or disabling the optimizer. Elapsed time is reset on reenable.
Adds an optimization to the optimizer with an optional priority.
The optimization to add. Can be an instance of Optimization
or a function.
The priority of the optimization. Defaults to 0 if not provided.
If the optimization
parameter is a function, it will be wrapped in an Optimization
instance.
The priority is parsed as an integer and defaults to 0 if parsing fails.
The optimization is then added to the internal optimizations list at the specified priority.
The minPriority
and maxPriority
properties are updated accordingly.
Adds a sample time to the optimizer and performs optimization logic.
The time of the sample to add, in milliseconds.
This method performs the following steps:
Disposes of the optimizer by removing event listeners for window blur and focus events. This helps to clean up resources and prevent memory leaks when the optimizer is no longer needed.
Restarts the optimizer by resetting its state.
This method performs the following actions:
resetCheck()
._increasingWork
property to the value of options.increaseWork
.currPriority
to null
.currOptimization
to 0
.completed
to false
.Updates the optimizer by ending the current process and beginning a new one. This method ensures that any ongoing operations are properly terminated before starting a new operation cycle.
The optimizer tracks the amount of time spent between frames or between calls to begin and end and calculates the difference between the target amount of time to spend and the actual time spent on the last frame.
After the specified amount of time has passed the average time spent is calculated and the framerate the amount of work is either increased or decreased depending on whether or not the time spent was above or below the target.
The amount of work is adjusted by iteratively calling prioritized optimizations and sampling framerate until the target work time is met.