# Rendimiento

El global `performance` y `node:perf_hooks` comparten una misma línea de tiempo.

## Temporización y entradas

```js
performance.now();        // milliseconds since timeOrigin
performance.mark("start");
performance.measure("work", "start");

performance.getEntriesByName("work")[0].entryType; // "measure"
```

`getEntries()`, `getEntriesByName()` y `getEntriesByType()` devuelven
arrays nuevos ordenados por tiempo de inicio. `clearMarks()` y `clearMeasures()`
eliminan las entradas coincidentes.

`PerformanceMark` se puede construir. `Performance`,
`PerformanceEntry` y `PerformanceMeasure` no se pueden construir
directamente.

## PerformanceObserver

```js
const observer = new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    console.log(entry.name, entry.entryType);
  }
});

observer.observe({ entryTypes: ["mark", "measure"] });
performance.mark("ready");
```

La entrega a los observadores se produce en un punto de control de microtareas. `disconnect()` detiene
la observación y borra las entradas almacenadas; `takeRecords()` vacía el búfer
actual.

`PerformanceObserver.supportedEntryTypes` contiene `mark`,
`measure`, `node` y `function`.

Los valores `detail` de las marcas y medidas usan el mismo comportamiento de clonación estructurada que
la [Mensajería web](/docs/api-wintercg-messaging). Tipos como `Date`, `RegExp`,
`Map`, `Set` y `ArrayBuffer` conservan su tipo y contenido; las funciones lanzan
`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 -->
