From 014b1f52678f377b8c1158f308c7323cc0b46b4f Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 15 Oct 2026 03:47:11 +0200 Subject: [PATCH] Benchmark reports go to the telemetry outbox, with the benchmark-upload consent only Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/benchmark.rs | 1 + crates/horizon-client/src/telemetry.rs | 47 ++++++++++++++++++++++++++ docs/benchmark.md | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/benchmark.rs b/crates/horizon-client/src/benchmark.rs index 00b0f1076..05e559914 100644 --- a/crates/horizon-client/src/benchmark.rs +++ b/crates/horizon-client/src/benchmark.rs @@ -255,6 +255,7 @@ fn run(control: &Control, setup: Setup) -> Result { if let Ok(meta) = std::env::current_exe().and_then(std::fs::metadata) { report.metric("game.binary_bytes", &[meta.len() as f64]); } + crate::telemetry::keep_benchmark(&crate::logging::game_home(), &report); report .write_to(&setup.game_dir.join("benchmarks")) .map_err(|e| e.to_string()) diff --git a/crates/horizon-client/src/telemetry.rs b/crates/horizon-client/src/telemetry.rs index 5abc3bd89..9e83655fa 100644 --- a/crates/horizon-client/src/telemetry.rs +++ b/crates/horizon-client/src/telemetry.rs @@ -105,6 +105,20 @@ pub fn keep_crash(home: &Path, report: &crate::crash::Report) { } } +/// Keeps a benchmark report (`--benchmark`) for the launcher to send, if the player allows +/// benchmark uploads: the report as docs/benchmark-report.md defines it, dated to the day. +pub fn keep_benchmark(home: &Path, report: &horizon_bench::Report) { + let Ok(data) = serde_json::to_value(report.for_upload()) else { + return; + }; + if let Err(e) = outbox::push( + home, + &Item::new(Source::Game, version(), Payload::Benchmark(data)), + ) { + log::warn!("Horizon: could not keep the benchmark report to send: {e}"); + } +} + /// One play session's performance, from entering a world to leaving it: frame and tick /// times as [`Timings`] (fixed size whatever the length), never the frames themselves. #[derive(Default)] @@ -303,6 +317,39 @@ mod tests { assert!(crash.stack.lines().count() > 100); } + #[test] + fn benchmark_reports_need_their_own_consent_and_go_dated_to_the_day() { + let home = home("benchmark"); + let mut report = horizon_bench::Report::new(horizon_bench::Kind::Game, Default::default()); + report.created = "2026-10-15T14:03:27Z".into(); + report.label = Some("my machine".into()); + keep_benchmark(&home, &report); + allow( + &home, + Choices { + performance: true, + ..Choices::NONE + }, + ); + keep_benchmark(&home, &report); + assert!(outbox::pending(&home).is_empty()); + allow( + &home, + Choices { + benchmarks: true, + ..Choices::NONE + }, + ); + keep_benchmark(&home, &report); + let pending = outbox::pending(&home); + assert_eq!(pending.len(), 1); + let text = serde_json::to_string(&pending[0].1).unwrap(); + assert!( + text.contains("2026-10-15T00:00:00Z") && !text.contains("my machine"), + "{text}" + ); + } + #[test] fn crashes_stay_local_without_consent() { let home = home("crash"); diff --git a/docs/benchmark.md b/docs/benchmark.md index 7a9bd5f13..6c5c35f8d 100644 --- a/docs/benchmark.md +++ b/docs/benchmark.md @@ -42,7 +42,7 @@ horizon-client --benchmark standard --render-distance 16 It starts at the title screen, creates the world `horizon-benchmark` (seed 1234, creative; the next run replaces it, and it never touches a world it didn't create), flies the four scenes as above, writes a report to `benchmarks/` in the game folder and quits. `--benchmark village` (or `forest`, `ocean`, `mountain`) flies one scene. For the run only, VSync is off, the frame rate unlimited and the game doesn't pause or slow down without focus; your options are not changed. Your other settings (render distance unless given, graphics, window size) are used as they are, and stored in the report, so compare reports with the same conditions. -The report is the [benchmark report format](benchmark-report.md): startup to the title screen and to in-world, each scene's chunk load time, chunks generated and section meshes built, every flight's frame figures and histogram, resident and GPU memory, the binary's size, and the machine (OS, CPU, RAM, GPU, driver, backend, display), the load average before the run and whether it ran on battery. It is the same file the telemetry upload would send with your consent; nothing is uploaded by the benchmark itself. +The report is the [benchmark report format](benchmark-report.md): startup to the title screen and to in-world, each scene's chunk load time, chunks generated and section meshes built, every flight's frame figures and histogram, resident and GPU memory, the binary's size, and the machine (OS, CPU, RAM, GPU, driver, backend, display), the load average before the run and whether it ran on battery. If you allowed benchmark uploads (the launcher's data collection choices, [docs/telemetry.md](telemetry.md)), the same report, dated to the day and without local fields, is kept for the launcher to send; otherwise it stays on your machine. ## Reproduce it