Skip to content

Proposal: compare command for two traces #10

Open

Description

@nucliweb

Follow-up to #9.

Use case

Check the impact of a change: record a trace on main and another on a PR branch, and see what changed. Today you run overview and other commands on both traces and compare the output by hand, or ask an agent to do it, which costs tokens and is easy to get wrong.

Sketch

trace-engine-cli compare baseline.json.gz candidate.json.gz

The output would include:

  • Core Web Vitals per metric: baseline, candidate, delta and rating change (for example good → needs-improvement).
  • Main thread busy time (total minus idle) per category. Idle is left out because two recordings rarely have the same length.
  • Long task count and blocking time (sum of dur - 50ms), named blockingMs so it is not confused with Lighthouse TBT.
  • Top function regressions by self time, reusing the aggregation in diff.
  • A warning if the main URLs differ.

Open questions

  • Noise: one trace per side gives noisy CWV deltas. A first version could compare a single pair and focus on rating changes. A later version could accept several traces per side and compare medians.
  • Naming: diff compares two windows in one trace, and compare would compare two traces. The names could be confusing.
  • Scope: does this belong in this CLI, or is it better left to the agent (run overview on both traces and compare)?

What are your main concerns about it?

Activity

  1. kurtextrem commented on Nov 21, 2026

    @kurtextrem
    Contributor

    I also think a compare function would be incredibly great. From talking to other devs, even a "compare traces A, B, C" may make sense (or 3x "before" and 3x "after", to sort out variance).

    This is of course non-trivial, so we may need to brainstorm (and iterate) on how this could look like, because comparing a trace that differs in length may not be so easy (and also if the bundle happens to have changed, matching JS functions).

  2. nucliweb commented on Nov 26, 2026

    @nucliweb
    ContributorAuthor

    @jackfranklin, following your comment in #9, let's continue the discussion here.

    @kurtextrem raised two important points: several traces per side help with variance, and function matching is hard when the bundle changes between traces.

    A narrow first version could be:

    • Accept one or more traces per side, and compare medians when there are several.
    • Compare only values that do not depend on trace length or code identity: Core Web Vitals and their ratings, long task count and blocking time, and main thread busy time per category.
    • Leave function-level regressions out of the first version, because function names and URLs change when the bundle changes.
    • Support --format json, so a CI job can check the deltas with jq -e, as in Document CI threshold checks with jq #26.

    The other option is no new command, and a README recipe that runs overview --format json on both traces and compares the values with jq. That costs less to maintain, but the agent or script must calculate the deltas and medians itself.

    Which option do you prefer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions