Skip to content

Add --import-json to combine results from separate runs (fixes #830)#894

Open
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:feat/import-json-830
Open

Add --import-json to combine results from separate runs (fixes #830)#894
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:feat/import-json-830

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 26, 2026

Summary

Adds a --import-json FILE option to load benchmark results from a previous --export-json export and include them in the summary and relative speed comparison of the current run.

This supports the common workflow of benchmarking a baseline, applying a system change, and then benchmarking again — without manually comparing two separate hyperfine outputs.

Example:

hyperfine --export-json baseline.json "dracut --debug --force"
# apply patch...
hyperfine --import-json baseline.json "dracut --debug --force"

Changes

  • Add --import-json CLI flag and Options::import_json
  • Deserialize JSON exports via load_benchmark_results() (restores display command when omitted)
  • Prepend imported results in Scheduler before running new benchmarks
  • Add unit and integration tests

Fixes #830

Test plan

  • cargo test
  • Integration test: export JSON, import it in a second run, verify relative comparison includes imported command
  • Integration test: fail early when import file does not exist

Made with Cursor

Allow importing a previous --export-json file so baseline and follow-up
benchmarks can be compared in a single summary without manual math.

Fixes sharkdp#830

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 591af06162

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +34 to +36
pub fn prepend_results(&mut self, mut imported_results: Vec<BenchmarkResult>) {
imported_results.append(&mut self.results);
self.results = imported_results;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve explicit reference position when importing results

Prepending imported results here shifts all newly measured benchmarks to the right, but print_relative_speed_comparison still assumes self.results[0] is the --reference benchmark when --reference is set. In runs that combine --import-json and --reference, the first imported entry is treated as the reference instead of the command passed via --reference, which produces incorrect relative-speed ratios and summary text for that workflow.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Support combining benchmark results

1 participant