FlameGraph
Where the time of a request or a profile goes: each bar is a function, as wide as the time spent in it, with what it called on the row below.
import { FlameGraph, FlameGraphSkeleton } from '@sypnia/ui/react'
One slow request
Where the time of a request goes
GET /orders, 840 ms
View as table
| Self | Share | |
|---|---|---|
| pg.execute | 310 ms | 36.9% |
| pg.connect | 180 ms | 21.4% |
| json.stringify | 110 ms | 13.1% |
| log.write | 60 ms | 7.1% |
| GET /orders | 48 ms | 5.7% |
| auth.verify | 30 ms | 3.6% |
| orders.list | 30 ms | 3.6% |
| db.query | 30 ms | 3.6% |
| serialize | 30 ms | 3.6% |
| jwt.decode | 12 ms | 1.4% |
Code
import { FlameGraph } from '@sypnia/ui/react';
// Where the 840 ms of one request went. The widest bars are what to look at. Press a bar to zoom in; the top bar goes back.
const root = {
name: 'GET /orders', value: 840, children: [
{ name: 'auth.verify', value: 42, children: [{ name: 'jwt.decode', value: 12 }] },
{ name: 'orders.list', value: 690, children: [
{ name: 'db.query', value: 520, children: [{ name: 'pg.connect', value: 180 }, { name: 'pg.execute', value: 310 }] },
{ name: 'serialize', value: 140, children: [{ name: 'json.stringify', value: 110 }] },
] },
{ name: 'log.write', value: 60 },
],
};
export default function Request() {
return <FlameGraph title="Where the time of a request goes" subtitle="GET /orders, 840 ms" root={root} />;
} Skeleton
Code
import { FlameGraphSkeleton } from '@sypnia/ui/react';
// The profile while it loads: rows of bars that narrow as they go down.
export default function Skeleton() {
return <FlameGraphSkeleton rows={4} />;
} When to use it
Use it when
- Finding what made a request slow.
- Profiles from the browser or the server.
Do not use it when
- Things that happen one after another in time: use Waterfall.
For everyone
- Each bar is a button named with its time and share; pressing it zooms in, the top bar zooms out.
- «View as table» lists the functions by their own time.
Props
| FlameGraph | Type | Default |
|---|---|---|
rootrequired | Frame | |
titlerequired | ReactNode | |
empty | ReactNode | |
error | ReactNode | |
formatValueDefaults to milliseconds, written the person's way. | Fmt | |
height | number | |
loading | boolean | |
rowHeight | number | 24 |
subtitleWhat is plotted and in what unit: «Requests per minute, last 24 hours». | ReactNode |
| FlameGraphSkeleton | Type | Default |
|---|---|---|
rowHeight | number | 24 |
rows | number | 5 |