bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Replace `DiagnosticId` by `DiagnosticPath`

Open LeshaInc opened this issue 2 years ago • 2 comments

Objective

Implements #9216

Solution

  • Replace DiagnosticId by DiagnosticPath. It's pre-hashed using const-fnv1a-hash crate, so it's possible to create path in const contexts.

Changelog

  • Replaced DiagnosticId by DiagnosticPath

  • Set default history length to 120 measurements (2 seconds on 60 fps).

    I've noticed hardcoded constant 20 everywhere and decided to change it to DEFAULT_MAX_HISTORY_LENGTH , which is set to new diagnostics by default. To override it, use with_max_history_length.

Migration Guide

- const UNIQUE_DIAG_ID: DiagnosticId = DiagnosticId::from_u128(42);
+ const UNIQUE_DIAG_PATH: DiagnosticPath = DiagnosticPath::const_new("foo/bar");

- Diagnostic::new(UNIQUE_DIAG_ID, "example", 10)
+ Diagnostic::new(UNIQUE_DIAG_PATH).with_max_history_length(10)

- diagnostics.add_measurement(UNIQUE_DIAG_ID, || 42);
+ diagnostics.add_measurement(&UNIQUE_DIAG_ID, || 42);

LeshaInc avatar Jul 24 '23 14:07 LeshaInc

Hey, can you resolve merge conflicts? I'd like to get this in and at first glance this seems well-made.

alice-i-cecile avatar Jan 14 '24 21:01 alice-i-cecile

I've resolved merge conflicts. Examples seem to work.

LeshaInc avatar Jan 15 '24 12:01 LeshaInc