diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 15:35:24 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 15:35:24 +0200 |
| commit | 99b02bf8c389a793df5d5986db05eed7e459f7b1 (patch) | |
| tree | bc4e36cfcd3c9ef9b067beed2eb5b68a75a45aa2 /internal/flags | |
| parent | 4ff17c30120d657b966f8a55188ba167dc875e64 (diff) | |
refactor: remove web flamegrapher and keep TUI-only
Diffstat (limited to 'internal/flags')
| -rw-r--r-- | internal/flags/flags.go | 37 | ||||
| -rw-r--r-- | internal/flags/flags_test.go | 49 |
2 files changed, 11 insertions, 75 deletions
diff --git a/internal/flags/flags.go b/internal/flags/flags.go index 503aefb..cc6e70a 100644 --- a/internal/flags/flags.go +++ b/internal/flags/flags.go @@ -54,23 +54,14 @@ type Flags struct { TracepointsToAttach []*regexp.Regexp TracepointsToExclude []*regexp.Regexp - // Flamegraph flags - PlainMode bool - FlamegraphEnable bool - LiveFlamegraph bool - TestFlames bool - TestLiveFlames bool - LiveInterval time.Duration - OpenCommand string - FlamegraphName string - FlamegraphJSON bool - TUIExportEnable bool - - // To convert ior data into native SVG format - IorDataFile string - IorWatchInterval time.Duration - CollapsedFields []string - CountField string + // Output/runtime flags + PlainMode bool + TestFlames bool + TestLiveFlames bool + LiveInterval time.Duration + TUIExportEnable bool + CollapsedFields []string + CountField string } // NewFlags returns a configuration instance initialized with project defaults. @@ -81,7 +72,6 @@ func NewFlags() Flags { EventMapSize: 4096 * 16, Duration: 900, LiveInterval: 200 * time.Millisecond, - FlamegraphName: "default", TUIExportEnable: true, CollapsedFields: []string{"comm", "tracepoint", "path"}, CountField: "count", @@ -184,19 +174,10 @@ func parse() error { tracepointsToExclude := flag.String("tpsExclude", "", "Comma separated list regexes for tracepoints to exclude") flag.BoolVar(&cfg.PlainMode, "plain", false, "Enable plain CSV output mode (disable TUI)") - flag.BoolVar(&cfg.FlamegraphEnable, "flamegraph", false, "Enable flamegraph builder") - flag.BoolVar(&cfg.LiveFlamegraph, "live", false, "Enable live flamegraph mode") flag.BoolVar(&cfg.TestFlames, "testflames", false, "Run TUI with static synthetic flamegraph data for keyboard-navigation testing") flag.BoolVar(&cfg.TestLiveFlames, "testliveflames", false, "Run TUI with continuously-updating synthetic flamegraph data for live keyboard-navigation testing") - flag.DurationVar(&cfg.LiveInterval, "live-interval", cfg.LiveInterval, "Live flamegraph refresh interval") - flag.StringVar(&cfg.OpenCommand, "open", "", "Command to open live flamegraph URL (used with -live); use {url} placeholder or URL is appended") - flag.StringVar(&cfg.FlamegraphName, "name", cfg.FlamegraphName, "Name of the flamegraph, used to generate the SVG file") - flag.BoolVar(&cfg.FlamegraphJSON, "flamegraphJson", false, "Also export flamegraph tree as JSON in -ior mode (experimental WASM-ready output)") + flag.DurationVar(&cfg.LiveInterval, "live-interval", cfg.LiveInterval, "Synthetic live flamegraph refresh interval for --testliveflames") flag.BoolVar(&cfg.TUIExportEnable, "tuiExport", cfg.TUIExportEnable, "Enable writing TUI snapshot export files") - - flag.StringVar(&cfg.IorDataFile, "ior", "", "IOR data file to convert into native SVG flamegraph") - flag.DurationVar(&cfg.IorWatchInterval, "iorWatchInterval", 0, - "In -ior mode, poll input file for changes and regenerate outputs; also enables auto-reloading viewer") fields := flag.String("fields", "", fmt.Sprintf("Comma separated list of fields to collapse, valid are: %v", validCollapsedFields)) flag.StringVar(&cfg.CountField, "count", cfg.CountField, diff --git a/internal/flags/flags_test.go b/internal/flags/flags_test.go index 7323438..08dd6a2 100644 --- a/internal/flags/flags_test.go +++ b/internal/flags/flags_test.go @@ -38,15 +38,12 @@ func parseForTest(t *testing.T, args ...string) (Flags, error) { return cfg, err } -func TestParseLiveFlagsAndInterval(t *testing.T) { - cfg, err := parseForTest(t, "-live", "-live-interval", "200ms", "-pid", "1234") +func TestParseLiveIntervalAndPID(t *testing.T) { + cfg, err := parseForTest(t, "-live-interval", "200ms", "-pid", "1234") if err != nil { t.Fatalf("parse returned error: %v", err) } - if !cfg.LiveFlamegraph { - t.Fatalf("expected -live to enable live mode") - } if cfg.LiveInterval != 200*time.Millisecond { t.Fatalf("live interval = %v, want %v", cfg.LiveInterval, 200*time.Millisecond) } @@ -56,9 +53,6 @@ func TestParseLiveFlagsAndInterval(t *testing.T) { if got := Get().GetPidFilter(); got != 1234 { t.Fatalf("Get().GetPidFilter() = %d, want 1234", got) } - if cfg.OpenCommand != "" { - t.Fatalf("expected empty open command by default") - } } func TestNewFlagsDefaultsAndGetters(t *testing.T) { @@ -83,48 +77,9 @@ func TestParseLiveDefaults(t *testing.T) { t.Fatalf("parse returned error: %v", err) } - if cfg.LiveFlamegraph { - t.Fatalf("expected live mode disabled by default") - } if cfg.LiveInterval != 200*time.Millisecond { t.Fatalf("default live interval = %v, want %v", cfg.LiveInterval, 200*time.Millisecond) } - if cfg.OpenCommand != "" { - t.Fatalf("expected empty open command by default") - } -} - -func TestParseOpenFlags(t *testing.T) { - cfg, err := parseForTest(t, "-live", "-open", "chromium --new-window") - if err != nil { - t.Fatalf("parse returned error: %v", err) - } - if !cfg.LiveFlamegraph { - t.Fatalf("expected live mode enabled") - } - if cfg.OpenCommand != "chromium --new-window" { - t.Fatalf("open command = %q, want %q", cfg.OpenCommand, "chromium --new-window") - } -} - -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 TestParseIorWatchIntervalFlag(t *testing.T) { - cfg, err := parseForTest(t, "-iorWatchInterval", "2s") - if err != nil { - t.Fatalf("parse returned error: %v", err) - } - if cfg.IorWatchInterval != 2*time.Second { - t.Fatalf("ior watch interval = %v, want %v", cfg.IorWatchInterval, 2*time.Second) - } } func TestParseTestFlamesFlag(t *testing.T) { |
