Skip to content

feat(profiler): GET /api/profiler/compare for the UI's Compare button - #494

Merged
butschster merged 1 commit into
masterfrom
fix/profiler-compare
Nov 22, 2026
Merged

butschster merged 1 commit into
masterfrom
fix/profiler-compare

Conversation

@butschster

Copy link
Copy Markdown
Member

Problem

The Profiler UI (since frontend 1.27.0, shipped 1.40.0) has a Compare button on each profile card. Picking two profiles opens /profiler/compare, which calls GET /api/profiler/compare?base=…&compare=…. The Go server had no such route: the request fell through to the SPA, the UI got HTML instead of JSON, and the comparison table stayed empty.

Change

  • modules/profiler/compare.go — new handler, route in api.go.
  • Response: {functions: [...], total, base_totals, compare_totals}. Each function row has function, base_/compare_/diff_ for excl_wt (µs), excl_mu (bytes) and ct — the fields profile-compare.vue reads.
  • Functions present in only one profile get 0 on the other side.
  • Sorted by biggest absolute wall-time change; limit default 100, max 1000.
  • 400 on missing params, 404 on unknown profile.
  • OpenAPI: /api/profiler/compare + ProfilerCompareTotals.

Verification

  • TestCompare (modules/profiler/compare_test.go): shape, missing side = 0, order, limit, 400/404.
  • go vet ./... clean, go test -count=1 ./... green.
  • Live: binary with frontend 1.40.0 embedded, two profiles posted, Compare clicked on both cards in headless Chrome → /api/profiler/compare answers 200 application/json, table shows 4 rows (a() 1.0ms→3.0ms +200%, b() gone, c() new, main()).

Made with harnsy

The released UI (frontend >= 1.27) calls /api/profiler/compare?base=&compare=
and reads functions[].{base,compare,diff}_{excl_wt,excl_mu,ct}; the Go
server had no such route, so the comparison page stayed empty.
Functions of either profile, missing side counts 0, biggest wall-time
change first, limit (default 100, max 1000), totals of both profiles.
@butschster butschster added the type: feature Net-new functionality label Nov 22, 2026
@butschster
butschster merged commit 7f5f97c into master Nov 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Net-new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant