summaryrefslogtreecommitdiff
path: root/internal/flags
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-03 13:00:38 +0200
committerPaul Buetow <paul@buetow.org>2026-03-03 13:00:38 +0200
commitf92382c20193a5366d15c7347dcc8ed2743f3b85 (patch)
tree11789e0336233501c778c521075f20c8d2c3558d /internal/flags
parent92e87642f2936f0da63d32113f75633b38be24f6 (diff)
Add WASM-ready flamegraph JSON export
Diffstat (limited to 'internal/flags')
-rw-r--r--internal/flags/flags.go2
-rw-r--r--internal/flags/flags_test.go10
2 files changed, 12 insertions, 0 deletions
diff --git a/internal/flags/flags.go b/internal/flags/flags.go
index a732c3a..bc1654b 100644
--- a/internal/flags/flags.go
+++ b/internal/flags/flags.go
@@ -67,6 +67,7 @@ type Flags struct {
LiveInterval time.Duration
OpenCommand string
FlamegraphName string
+ FlamegraphJSON bool
TUIExportEnable bool
// To convert ior data into native SVG format
@@ -125,6 +126,7 @@ func parse() error {
flag.DurationVar(&singleton.LiveInterval, "live-interval", 200*time.Millisecond, "Live flamegraph refresh interval")
flag.StringVar(&singleton.OpenCommand, "open", "", "Command to open live flamegraph URL (used with -live); use {url} placeholder or URL is appended")
flag.StringVar(&singleton.FlamegraphName, "name", "default", "Name of the flamegraph, used to generate the SVG file")
+ flag.BoolVar(&singleton.FlamegraphJSON, "flamegraphJson", false, "Also export flamegraph tree as JSON in -ior mode (experimental WASM-ready output)")
flag.BoolVar(&singleton.TUIExportEnable, "tuiExport", true, "Enable writing TUI snapshot export files")
flag.StringVar(&singleton.IorDataFile, "ior", "", "IOR data file to convert into native SVG flamegraph")
diff --git a/internal/flags/flags_test.go b/internal/flags/flags_test.go
index 32af4bd..11414d8 100644
--- a/internal/flags/flags_test.go
+++ b/internal/flags/flags_test.go
@@ -104,6 +104,16 @@ func TestParseOpenFlags(t *testing.T) {
}
}
+func TestParseFlamegraphJSONFlag(t *testing.T) {
+ cfg, err := parseForTest(t, "-flamegraphJson")
+ if err != nil {
+ t.Fatalf("parse returned error: %v", err)
+ }
+ if !cfg.FlamegraphJSON {
+ t.Fatalf("expected -flamegraphJson to enable JSON export")
+ }
+}
+
func TestParseDefaultCollapsedFieldsOrder(t *testing.T) {
cfg, err := parseForTest(t)
if err != nil {