Skip to content

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'

On this page
  1. One slow request
  2. Skeleton
  3. When to use it
  4. For everyone
  5. Props

One slow request

Where the time of a request goes
GET /orders, 840 ms
View as table
SelfShare
pg.execute310 ms36.9%
pg.connect180 ms21.4%
json.stringify110 ms13.1%
log.write60 ms7.1%
GET /orders48 ms5.7%
auth.verify30 ms3.6%
orders.list30 ms3.6%
db.query30 ms3.6%
serialize30 ms3.6%
jwt.decode12 ms1.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

FlameGraphTypeDefault
rootrequired Frame
titlerequired ReactNode
empty ReactNode
error ReactNode
formatValue

Defaults to milliseconds, written the person's way.

Fmt
height number
loading boolean
rowHeight number 24
subtitle

What is plotted and in what unit: «Requests per minute, last 24 hours».

ReactNode
FlameGraphSkeletonTypeDefault
rowHeight number 24
rows number 5
  1. One slow request
  2. Skeleton
  3. When to use it
  4. For everyone
  5. Props

    Search pages, sections and terms