# @webruntime/performance

> Lightning Web Runtime - Utilities

Latest version **1.61.4** (published 2021-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @webruntime/performance
pnpm add @webruntime/performance
yarn add @webruntime/performance
bun add @webruntime/performance
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.61.4 |
| Published | 2021-07-23 |
| First published | 2020-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 175.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | tconn, diervo, zhawtof, kjkimsfdc, lwc-admin |

## Links

- npm: https://www.npmjs.com/package/@webruntime/performance
- npm.io page: https://npm.io/package/@webruntime/performance

## Recent versions

- 1.61.4 (latest) — 2021-07-23
- 0.61.2-234.9 (winter22) — 2021-09-15
- 1.61.5-alpha.1711 (canary) — 2021-07-27
- 0.49.6-232.2 (summer21) — 2021-04-26
- 0.42.6-230.3 (spring21) — 2021-02-11
- 0.33.24-228.1 (winter21) — 2020-08-07
- 0.29.13-226.1 (summer20) — 2020-04-13
- 0.61.2-234.8 — 2021-08-18
- 0.61.2-234.7 — 2021-08-12
- 0.61.2-234.6 — 2021-08-11
- 0.61.2-234.5 — 2021-08-04
- 0.61.2-234.4 — 2021-07-31
- 0.61.2-234.3 — 2021-07-30
- 0.61.2-234.2 — 2021-07-28
- 0.61.2-234.1 — 2021-07-28
- … 252 more at https://npm.io/package/@webruntime/performance/versions

## README

# Lightning Web Runtime :: Performance

This package contains a utility for recording runtime performance.

## Getting Started

Install:

```
npm install @webruntime/performance
```

## Usage

### Measuring

This package provides two functions for manually starting and ending performance time measurements and a typescript decorator for automatically recording the runtime of decorated class methods.

```javascript
const { endMeasure, startMeasure } = require('@webruntime/performance');

function fib(n) {
    startMeasure(`fib-${n}`);
    let res = n === 1 || n === 2 ? 1 : fib(n - 1) + fib(n - 2);
    endMeasure(`fib-${n}`);
    return res;
}
```

```typescript
import { Measure } from '@webruntime/performance';

class FibonacciCalculator {
    ...

    @Measure(n => `fib-${n}`)
    calculate (n: number) {
        return n === 1 || n === 2 ? 1 : fib(n-1) + fib(n-2);
    }
}
```

### Collecting Measurements

This package does not currently log the timing measurements being recorded by the utility due to LWR not yet having a configurable logger. For now, users can use a [PerformanceObserver](https://nodejs.org/api/perf_hooks.html#perf_hooks_class_performanceobserver).

```javascript
const { PerformanceObserver } = require('perf_hooks');

const observer = new PerformanceObserver(observe);
observer.observe({
    entryTypes: ['measure'],
    buffered: false,
});

function observe(list) {
    const entries = list.getEntries();

    entries.forEach((entry) => {
        console.log(entry);
    });
}
```

---
_Source: https://npm.io/package/@webruntime/performance · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
