-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Benchmarks of private code not running on macOS #61
Comments
This is what I see too. The "register anywhere" feature seems to be broken on macOS (I'm on Sequoia, |
@Fraser999 Did you by any chance dig deeper into this yet? Do you have a hunch about where the problem lies and/or which macOS version broke it? |
No, I'm afraid I've not had time.
Also no. For reference, I'm on Sonoma (14.6.1). Potentially it has never worked on macOS, since the example here works for me and that's what's used in CI to test this functionality. |
Yeah the example works for me too, always did. Never figured out how to do it outside the divan crate though. It's such a killer feature, sad it's incomplete. |
The best solution I've found so far is to a) create a feature flag that you can use to conditionally compile benchmark modules, b) put the Note that you should only call So your [package]
name = "foo"
...
[dependencies]
divan = { version = "0.1.14", optional = true }
[features]
bench = ["dep:divan"]
[[bench]]
name = "benchmark"
harness = false You have mod bar;
mod baz;
#[cfg(feature = "bench")]
pub mod benchmarks {
pub fn main() {
divan::main();
}
// This is a good place to put any common code that is only
// used in benchmarking
pub fn my_bench_util() { ... }
} You have fn my_private_fn() {
...
}
#[cfg(feature = "bench")]
mod benchmarks {
use crate::benchmarks::my_bench_util;
fn bench_my_private_fn() {
my_bench_util();
divan::black_box(super::my_private_fn());
}
} And you have a fn main() {
foo::benchmarks::main();
} To run benchmarks: This isn't as nice as having the |
This is quite unfortunate, but thanks @jdidion for finding a decent workaround! I'll leave this issue open until this works as expected. |
@jdidion I ran into the @nvzqz I did some debugging on this issue; I didn't get super far, but I did manage to prove to myself that the benchmark does make it into the |
I created a small repo to demonstrate the issue.
In the root, if I run
cargo bench
on Ubuntu, I see the expected benchmarking output, but on macOS, I don't.The text was updated successfully, but these errors were encountered: