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
- func BytesToMB(bytes int64) string
- func CPUPercent(ticks0, ticks1 uint64, elapsed time.Duration, hz int) float64
- func IsFramesLine(line string) bool
- func KBToMB(kb int) string
- func Median(d []time.Duration) time.Duration
- func Ms(d time.Duration) string
- func Ms2(d time.Duration) string
- func ParseLogLine(line string) map[string]string
- func ParseLogTime(line string, loc *time.Location) (time.Time, bool)
- func ProcMemory(status string) (rssKB, hwmKB int, ok bool)
- func ProcTicks(stat string) (ticks uint64, ok bool)
- func RollupPSS(rollup string) (pssKB int, ok bool)
- type Doc
- type DurStats
- type FrameSummary
- type Frames
- type Table
Constants ¶
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 CPUPercent ¶
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 ¶
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 Median ¶
Median is the middle value of the durations (the upper one for an even count), or zero for none.
Flutter: no counterpart
func ParseLogLine ¶
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 ¶
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 ¶
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
Types ¶
type Doc ¶
Doc is a report as key/value lines and tables, which both formats print.
Flutter: no counterpart
type DurStats ¶
DurStats is the minimum, the median and the maximum of some durations.
Flutter: no counterpart
func SummarizeDurations ¶
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 ¶
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