Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Unrecognized Option" error when using Criterion-specific arguments in benchmarks #17222

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
unsafe_op_in_unsafe_fn = "warn"
unused_qualifications = "warn"

[lib]
# This fixes the "Unrecognized Option" error when running commands like
# `cargo bench -- --save-baseline before` by disabling the default benchmark harness.
# See <https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options>
# for more information.
bench = false

[[bench]]
name = "ecs"
path = "benches/bevy_ecs/main.rs"
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_render/src/extract_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use bevy_app::{App, Plugin};
use bevy_ecs::prelude::*;
pub use bevy_render_macros::ExtractResource;
use bevy_utils::once;
use tracing::{error, warn};

use crate::{Extract, ExtractSchedule, RenderApp};

Expand Down Expand Up @@ -36,7 +35,7 @@ impl<R: ExtractResource> Plugin for ExtractResourcePlugin<R> {
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
render_app.add_systems(ExtractSchedule, extract_resource::<R>);
} else {
once!(error!(
once!(tracing::error!(
"Render app did not exist when trying to add `extract_resource` for <{}>.",
core::any::type_name::<R>()
));
Expand All @@ -58,12 +57,13 @@ pub fn extract_resource<R: ExtractResource>(
} else {
#[cfg(debug_assertions)]
if !main_resource.is_added() {
once!(warn!(
once!(tracing::warn!(
"Removing resource {} from render world not expected, adding using `Commands`.
This may decrease performance",
core::any::type_name::<R>()
));
}

commands.insert_resource(R::extract_resource(main_resource));
}
}
Expand Down
Loading