Skip to main content

Crate cpuprofile_to_pprof

Crate cpuprofile_to_pprof 

Source
Expand description

Convert Node V8 .cpuprofile (Inspector Profiler.Profile) JSON into gzip’d pprof protobuf.

Port of the TypeScript implementation that lived in @mizchi/pprof-tools/cpuprofile-to-pprof. The cpuprofile schema is a tree of nodes (nodes[i].children lists child ids) plus a samples array of leaf node ids and a timeDeltas array (μs) holding the elapsed time between consecutive samples. We invert children into a parent map, aggregate samples by leaf node, and emit one pprof Sample per unique leaf with both samples/count and cpu/nanoseconds values.

Symbol names go through a caller-supplied demangler. Defaults to moonbit_demangle::demangle; pass identity (|s| s.into()) when profiling non-MoonBit code.

Structs§

Builder
Builds a pprof Profile from a parsed CpuProfile.
CallFrame
V8 call frame (CallFrame in the Inspector domain).
CpuNode
One node in the cpuprofile call tree.
CpuProfile
Parsed shape of Profiler.Profile (.cpuprofile JSON).
EncodedProfile
Output of Builder::encode — gzip’d bytes plus counts.
Stats
Conversion stats returned alongside the encoded bytes.

Type Aliases§

DemangleFn
Demangler hook — (name) → pretty name. Defaults to moonbit_demangle::demangle.