You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to get the code in examples/criterion working in order to be able to generate a flamegraph in Criterion.
I have the following Cargo.toml file
[package]
name = "operation_tree"
version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.8"
[dev-dependencies]
criterion = "0.5"
pprof = { version = "0.13", features = ["flamegraph", "criterion"] }
[[bench]]
name = "my_benchmark"
harness = false
My benchmarking script is benches/my_benchmark.rs
extern crate operation_tree;
use criterion::{criterion_group, criterion_main, Criterion};
use pprof::{
criterion::{Output, PProfProfiler},
flamegraph::Options,
};
use rand::Rng;
fn criterion_benchmark(c: &mut Criterion) {
let mut rng = rand::thread_rng();
let x: Vec<f64> = (0..1000).map(|_x| rng.gen_range(0.0..10.0)).collect();
c.bench_function("operation_tree", |b| b.iter(|| operation_tree::add_two(&x)));
}
//criterion_group!(benches, criterion_benchmark);
criterion_group! {
name = benches;
config = Criterion::default().with_profiler(PProfProfiler::new(100,Output::Flamegraph(Some(Options::default()))));
targets = criterion_benchmark
}
criterion_main!(benches);
For the following src/lib.rs
pub fn add_two(x: &[f64]) -> Vec<f64> {
let mut y = Vec::new();
for i in 0..x.len() {
y.push(x[i] * 2.0);
}
y
}
I ran cargo bench --bench my_benchmark and Criterion ran the benchmarks and I can see the results in target/criterion/operation_tree/ folder. However, there is no flamegraph generated. I am trying to get a minimum working example on this simple code. Is there any setting I am missing?
The text was updated successfully, but these errors were encountered:
I was trying to get the code in
examples/criterion
working in order to be able to generate a flamegraph in Criterion.I have the following
Cargo.toml
fileMy benchmarking script is
benches/my_benchmark.rs
For the following
src/lib.rs
I ran
cargo bench --bench my_benchmark
and Criterion ran the benchmarks and I can see the results intarget/criterion/operation_tree/
folder. However, there is no flamegraph generated. I am trying to get a minimum working example on this simple code. Is there any setting I am missing?The text was updated successfully, but these errors were encountered: