# Performance

> How Elide supports `performance`, PerformanceObserver and PerformanceEntry per the User Timing and Performance Timeline specs, shared with node:perf_hooks.

`performance`, `PerformanceObserver`, and the `PerformanceEntry` classes are globals and follow the
[User Timing](https://w3c.github.io/user-timing/) and
[Performance Timeline](https://w3c.github.io/performance-timeline/) specs.

## Example

```js
// performance.mjs
const start = performance.now();
performance.mark("parse:start");
JSON.parse(JSON.stringify(Array.from({ length: 1000 }, (_, i) => ({ i }))));
performance.mark("parse:end", { detail: { rows: 1000 } });

const measure = performance.measure("parse", "parse:start", "parse:end");
console.log(measure.entryType, measure.name, measure.duration >= 0);
console.log(performance.getEntriesByName("parse:end")[0].detail.rows);
console.log(performance.now() >= start, typeof performance.timeOrigin);
```

`elide run performance.mjs` prints:

```text
measure parse true
1000
true number
```

## Differences from browsers

- `performance` and [node:perf_hooks](https://elide.help/docs/api-node-perf-hooks) share one timeline.
- `PerformanceObserver.supportedEntryTypes` is `mark`, `measure`, `node`, and `function`.
- Mark and measure `detail` values are cloned as in [Web Messaging](https://elide.help/docs/api-wintercg-messaging); functions throw
  `DataCloneError`.

<!-- api-reference:start 67c84b4e6a82 -->
## Reference

**Status:** Full · Not measured · since 1.1.0

### Exports

| Export | Kind | Status | Notes |
| --- | --- | --- | --- |
| `PerformanceEntry` | class | Full | `name`, `entryType`, `startTime`, `duration`, `detail`, `toJSON()` |
| `PerformanceMark` | class | Full | `detail` |
| `PerformanceMeasure` | class | Full | `detail` |
| `PerformanceObserverEntryList` | class | Full | `getEntries()`, `getEntriesByName()`, `getEntriesByType()` |
| `PerformanceObserver` | class | Full | `observe()`, `disconnect()`, `takeRecords()`, `PerformanceObserver.supportedEntryTypes` |
| `Performance` | class | Full | `now()`, `timeOrigin`, `mark()`, `measure()`, `getEntries()`, `getEntriesByName()`, `getEntriesByType()`, `clearMarks()`, `clearMeasures()`, `toJSON()` |
<!-- api-reference:end -->
