diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-03 13:00:38 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-03 13:00:38 +0200 |
| commit | f92382c20193a5366d15c7347dcc8ed2743f3b85 (patch) | |
| tree | 11789e0336233501c778c521075f20c8d2c3558d /internal/flamegraph/nativesvg.go | |
| parent | 92e87642f2936f0da63d32113f75633b38be24f6 (diff) | |
Add WASM-ready flamegraph JSON export
Diffstat (limited to 'internal/flamegraph/nativesvg.go')
| -rw-r--r-- | internal/flamegraph/nativesvg.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/flamegraph/nativesvg.go b/internal/flamegraph/nativesvg.go index 8a2bcd5..80061b4 100644 --- a/internal/flamegraph/nativesvg.go +++ b/internal/flamegraph/nativesvg.go @@ -58,18 +58,26 @@ func (n NativeSVG) WriteSVGFromFile(iorDataFile string) (outFile string, err err } func (n NativeSVG) WriteSVGFromIter(records iter.Seq[IterRecord], w io.Writer) error { + tr, err := n.buildTrieFromIter(records) + if err != nil { + return err + } + return WriteSVG(w, tr, n.config) +} + +func (n NativeSVG) buildTrieFromIter(records iter.Seq[IterRecord]) (*trie, error) { tr := newTrie() var framesBuf []string for record := range records { frames, err := n.recordFrames(record, framesBuf) if err != nil { - return err + return nil, err } framesBuf = frames tr.add(frames, record.Cnt.ValueByName(n.countField)) } tr.computeTotals() - return WriteSVG(w, tr, n.config) + return tr, nil } func (n NativeSVG) recordFrames(record IterRecord, framesBuf []string) ([]string, error) { |
