perfstats

package
v1.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package perfstats reads the engine's log lines that the performance tools measure with: the "first frame presented" line, the per-second "frames" statistics of GLUTTER_FRAME_STATS=1 and the key=value pairs of slog's text format. It also sums the frames of a window up, reads the counters of /proc (CPU ticks, VmRSS, Pss) and renders a report as text or Markdown tables. internal/webtest (the web), cmd/glutter-android (Android) and cmd/glutter-windows (Windows, under Wine) use it. It has no dependency on the platform.

Flutter: no counterpart

Index

Constants

View Source
const TagPerfWriteFailed = "PerfWriteFailed"

TagPerfWriteFailed is the tag of the error for a report that cannot be written to its writer.

Variables

This section is empty.

Functions

func BytesToMB

func BytesToMB(bytes int64) string

BytesToMB formats bytes as megabytes with two decimals.

Flutter: no counterpart

func CPUPercent

func CPUPercent(ticks0, ticks1 uint64, elapsed time.Duration, hz int) float64

CPUPercent is the CPU time between two readings of utime+stime (in ticks of hz a second) as a percentage of one core over the elapsed wall time; 0 for no time, a counter that went back, or no tick rate.

Flutter: no counterpart

func IsFramesLine

func IsFramesLine(line string) bool

IsFramesLine reports whether a log line looks like a "frames" statistics line: the message "frames" of the default logger ("INFO frames fps=...") or of slog's text handler ("msg=frames"). ParseFramesLine says whether it also has every value.

Flutter: no counterpart

func KBToMB

func KBToMB(kb int) string

KBToMB formats kilobytes as megabytes with one decimal.

Flutter: no counterpart

func Median

func Median(d []time.Duration) time.Duration

Median is the middle value of the durations (the upper one for an even count), or zero for none.

Flutter: no counterpart

func Ms

func Ms(d time.Duration) string

Ms formats a duration as milliseconds with one decimal.

Flutter: no counterpart

func Ms2

func Ms2(d time.Duration) string

Ms2 formats a duration as milliseconds with two decimals.

Flutter: no counterpart

func ParseLogLine

func ParseLogLine(line string) map[string]string

ParseLogLine splits a log line of the engine (slog's text format, key=value with values in quotes when they hold blanks) into its pairs.

Flutter: no counterpart

func ParseLogTime

func ParseLogTime(line string, loc *time.Location) (time.Time, bool)

ParseLogTime reads the time at the start of a line of the default logger ("2026/10/26 03:28:05 INFO ..."), in the given location; ok is false for a line that does not start with one. A program under Wine logs the time of the host, so the location is the host's.

Flutter: no counterpart

func ProcMemory

func ProcMemory(status string) (rssKB, hwmKB int, ok bool)

ProcMemory reads VmRSS and VmHWM, in kilobytes, from the text of /proc/<pid>/status. ok is false when VmRSS is missing (a kernel thread, or a process that ended).

Flutter: no counterpart

func ProcTicks

func ProcTicks(stat string) (ticks uint64, ok bool)

ProcTicks returns utime+stime in clock ticks from the text of /proc/<pid>/stat. The second field, the command in parentheses, may hold blanks and parentheses, so the fields are counted from the last ')'. ok is false for text that is not a stat line.

Flutter: no counterpart

func RollupPSS

func RollupPSS(rollup string) (pssKB int, ok bool)

RollupPSS reads Pss, in kilobytes, from the text of /proc/<pid>/smaps_rollup; ok is false when it has none.

Flutter: no counterpart

Types

type Doc

type Doc struct {
	Head   [][2]string
	Tables []Table
}

Doc is a report as key/value lines and tables, which both formats print.

Flutter: no counterpart

func (Doc) Render

func (doc Doc) Render(w io.Writer, program, format string) error

Render writes the document as "text" (aligned columns) or "markdown" (for docs/PERFORMANCE.md); program is the name in its first line ("glutter-android perf"). It fails with PerfWriteFailed when w does.

Flutter: no counterpart

type DurStats

type DurStats struct {
	N                int
	Min, Median, Max time.Duration
}

DurStats is the minimum, the median and the maximum of some durations.

Flutter: no counterpart

func SummarizeDurations

func SummarizeDurations(d []time.Duration) DurStats

SummarizeDurations computes DurStats; the zero value for none.

Flutter: no counterpart

type FrameSummary

type FrameSummary struct {
	// Seconds is the number of statistics lines (a second without a frame has none) and Frames
	// the frames in them.
	Seconds, Frames int
	// MeanFPS is the frames of the seconds that had some, per second; MinFPS and MaxFPS are the
	// lowest and the highest second.
	MeanFPS        float64
	MinFPS, MaxFPS int
	// BuildAvg and RasterAvg are the averages over all frames; BuildMax and RasterMax the worst
	// frame; WorstSecond the highest average build+raster of one second.
	BuildAvg, RasterAvg, BuildMax, RasterMax, WorstSecond time.Duration
	// Over16 is the number of frames over a 60th of a second, and Over16Percent its share.
	Over16        int
	Over16Percent float64
	// HeapMaxMB and HeapLastMB are the Go heap in use, SysLastMB what the runtime got from the
	// system.
	HeapMaxMB, HeapLastMB, SysLastMB int
}

FrameSummary sums up the per-second statistics lines of a window.

Flutter: no counterpart

func SummarizeFrames

func SummarizeFrames(fr []Frames) FrameSummary

SummarizeFrames computes FrameSummary; the zero value for none.

Flutter: no counterpart

type Frames

type Frames struct {
	Renderer string
	// FPS is the number of frames drawn in the second.
	FPS int
	// Build and Raster are the average and the worst time on the UI goroutine of the build
	// (build, layout, paint and the scene) and of the renderer's calls; Over16 is the number of
	// frames whose sum was over a 60th of a second.
	BuildAvg, BuildMax, RasterAvg, RasterMax time.Duration
	Over16                                   int
	// GoHeapMB and GoSysMB are the memory of the Go runtime.
	GoHeapMB, GoSysMB int
}

Frames is one "frames" line of the engine's statistics (GLUTTER_FRAME_STATS=1): the frames of one second.

Flutter: no counterpart

func ParseFramesLine

func ParseFramesLine(line string) (Frames, bool)

ParseFramesLine reads a "frames" line of the engine's statistics; ok is false for a line that is not one or has a value that is not a number or a duration.

Flutter: no counterpart

type Table

type Table struct {
	Title  string
	Header []string
	Rows   [][]string
}

Table is a titled table of text cells: rendered as aligned columns or as a Markdown table.

Flutter: no counterpart

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL