# MiniStats

Class · category: Other

Source: https://github.com/playcanvas/engine/blob/b5b983982a9860d21e0c1dafb2f85f72e2c01afb/src/extras/mini-stats/mini-stats.js#L86

MiniStats is a small graphical overlay that displays realtime performance metrics. By default,
it shows CPU and GPU utilization, frame timings and draw call count. It can also be configured
to display additional graphs based on data collected into `AppBase#stats`.

The detailed per-frame sub-timings — script, anim, physics and gsplat sort — are measured in
every build. The render timing is the exception: its start timestamp is only recorded in the
debug and profiler builds, so in the release build the render graph reports the time elapsed
since page load rather than a frame time. Import from `'playcanvas/debug'` or
`'playcanvas/profiler'` for a meaningful render figure.

## Constructors

### constructor

```ts
new MiniStats(app: AppBase, options?: MiniStatsOptions)
```

Create a new MiniStats instance.

**Parameters**

- `app` ([`AppBase`](https://api.playcanvas.com/engine/classes/AppBase.md)): The application.
- `options` ([`MiniStatsOptions`](https://api.playcanvas.com/engine/interfaces/MiniStatsOptions.md), optional): Options for the MiniStats instance.

**Example**

```ts
// create a new MiniStats instance using default options
const miniStats = new MiniStats(app);
```

## Accessors

### enabled

```ts
get enabled(): boolean
set enabled(value: boolean)
```

Gets the enabled state of the MiniStats overlay.

## Methods

### destroy

```ts
destroy(): void
```

Destroy the MiniStats instance.

**Example**

```ts
miniStats.destroy();
```

### getDefaultOptions

```ts
static getDefaultOptions(extraStats?: string[]): any
```

Returns the default options for MiniStats. The default options configure the overlay to
show the following graphs:

- CPU utilization
- GPU utilization
- Overall frame time
- Draw call count
- Total VRAM usage

**Parameters**

- `extraStats` (`string[]`, optional, default `[]`): Optional array of preset names from
  MiniStats.statPresets to include. The preset stats are inserted after the 'Frame'
  entry. Can be: 'gsplats', 'gsplatsCopy'.

**Returns** `any`: The default options for MiniStats.

**Example**

```ts
// default options without extra stats
const options = MiniStats.getDefaultOptions();
```

**Example**

```ts
// include gsplat stats
const options = MiniStats.getDefaultOptions(['gsplats', 'gsplatsCopy']);
```
