FrameRateMonitor - Cesium Documentation

# FrameRateMonitor

#### new FrameRateMonitor(options)

  Monitors the frame rate (frames per second) in a `Scene` and raises an event if the frame rate is lower than a threshold. Later, if the frame rate returns to the required level, a separate event is raised. To avoid creating multiple FrameRateMonitors for a single `Scene`, use `FrameRateMonitor.fromScene` instead of constructing an instance explicitly.

  Name | Type | Description
  --- | --- | ---

  `options`

  Object

  optional Object with the following properties:

  Name | Type | Default | Description
  --- | --- | --- | ---
  `scene` | Scene |  | The Scene instance for which to monitor performance.
  `samplingWindow` | Number | `5.0` | optional The length of the sliding window over which to compute the average frame rate, in seconds.
  `quietPeriod` | Number | `2.0` | optional The length of time to wait at startup and each time the page becomes visible (i.e. when the user switches back to the tab) before starting to measure performance, in seconds.
  `warmupPeriod` | Number | `5.0` | optional The length of the warmup period, in seconds. During the warmup period, a separate (usually lower) frame rate is required.
  `minimumFrameRateDuringWarmup` | Number | `4` | optional The minimum frames-per-second that are required for acceptable performance during the warmup period. If the frame rate averages less than this during any samplingWindow during the warmupPeriod, the lowFrameRate event will be raised and the page will redirect to the redirectOnLowFrameRateUrl, if any.
  `minimumFrameRateAfterWarmup` | Number | `8` | optional The minimum frames-per-second that are required for acceptable performance after the end of the warmup period. If the frame rate averages less than this during any samplingWindow after the warmupPeriod, the lowFrameRate event will be raised and the page will redirect to the redirectOnLowFrameRateUrl, if any.

  Source: Scene/FrameRateMonitor.js, line 45

### Members

#### staticFrameRateMonitor.defaultSettings

  The default frame rate monitoring settings. These settings are used when `FrameRateMonitor.fromScene` needs to create a new frame rate monitor, and for any settings that are not passed to the `FrameRateMonitor` constructor.
  Source: Scene/FrameRateMonitor.js, line 137

#### lastFramesPerSecond :Number

  Gets the most recently computed average frames-per-second over the last `samplingWindow`. This property may be undefined if the frame rate has not been computed.
  Source: Scene/FrameRateMonitor.js, line 212

#### lowFrameRate :Event

  Gets the event that is raised when a low frame rate is detected. The function will be passed the `Scene` instance as its first parameter and the average number of frames per second over the sampling window as its second parameter.
  Source: Scene/FrameRateMonitor.js, line 187

#### minimumFrameRateAfterWarmup :Number

  Gets or sets the minimum frames-per-second that are required for acceptable performance after the end of the warmup period. If the frame rate averages less than this during any `samplingWindow` after the `warmupPeriod`, the `lowFrameRate` event will be raised and the page will redirect to the `redirectOnLowFrameRateUrl`, if any.
  Source: Scene/FrameRateMonitor.js, line 88

#### minimumFrameRateDuringWarmup :Number

  Gets or sets the minimum frames-per-second that are required for acceptable performance during the warmup period. If the frame rate averages less than this during any `samplingWindow` during the `warmupPeriod`, the `lowFrameRate` event will be raised and the page will redirect to the `redirectOnLowFrameRateUrl`, if any.
  Source: Scene/FrameRateMonitor.js, line 80

#### nominalFrameRate :Event

  Gets the event that is raised when the frame rate returns to a normal level after having been low. The function will be passed the `Scene` instance as its first parameter and the average number of frames per second over the sampling window as its second parameter.
  Source: Scene/FrameRateMonitor.js, line 200

#### quietPeriod :Number

  Gets or sets the length of time to wait at startup and each time the page becomes visible (i.e. when the user switches back to the tab) before starting to measure performance, in seconds.
  Source: Scene/FrameRateMonitor.js, line 65

#### samplingWindow :Number

  Gets or sets the length of the sliding window over which to compute the average frame rate, in seconds.
  Source: Scene/FrameRateMonitor.js, line 58

#### scene :Scene

  Gets the `Scene` instance for which to monitor performance.
  Source: Scene/FrameRateMonitor.js, line 174

#### warmupPeriod :Number

  Gets or sets the length of the warmup period, in seconds. During the warmup period, a separate (usually lower) frame rate is required.
  Source: Scene/FrameRateMonitor.js, line 72

### Methods

#### staticFrameRateMonitor.fromScene(scene) → FrameRateMonitor

  Gets the `FrameRateMonitor` for a given scene. If the scene does not yet have a `FrameRateMonitor`, one is created with the `FrameRateMonitor.defaultSettings`.

  Name | Type | Description
  --- | --- | ---
  `scene` | Scene | The scene for which to get the `FrameRateMonitor`.

  ##### Returns:

  The scene's `FrameRateMonitor`.
  Source: Scene/FrameRateMonitor.js, line 152

#### destroy() → undefined

  Unsubscribes this instance from all events it is listening to. Once an object is destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception. Therefore, assign the return value (`undefined`) to the object as done in the example.

  ##### Returns:

  ##### Throws:

  - DeveloperError : This object was destroyed, i.e., destroy() was called.

  ##### See:

  - FrameRateMonitor#isDestroyed
  Source: Scene/FrameRateMonitor.js, line 276

#### isDestroyed() → Boolean

  Returns true if this object was destroyed; otherwise, false.
  If this object was destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception.

  ##### Returns:

  True if this object was destroyed; otherwise, false.

  ##### See:

  - FrameRateMonitor#destroy
  Source: Scene/FrameRateMonitor.js, line 258

#### pause()

  Pauses monitoring of the frame rate. To resume monitoring, `FrameRateMonitor#unpause` must be called once for each time this function is called.
  Source: Scene/FrameRateMonitor.js, line 224

#### unpause()

  Resumes monitoring of the frame rate. If `FrameRateMonitor#pause` was called multiple times, this function must be called the same number of times in order to actually resume monitoring.
  Source: Scene/FrameRateMonitor.js, line 238