-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
42 lines (31 loc) · 836 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use rust_cubes::cube_generators::Cubes;
fn main() {
if let Some(arg) = std::env::args().nth(1) {
call_generate(arg.parse().unwrap());
} else {
panic!("Expected an argument.");
}
}
#[cfg(not(feature = "pprof"))]
fn call_generate(n: usize) {
generate(n);
}
#[cfg(feature = "pprof")]
fn call_generate(n: usize) {
let guard = pprof::ProfilerGuardBuilder::default()
.frequency(1000)
.blocklist(&["libc", "libgcc", "pthread", "vdso"])
.build().unwrap();
generate(n);
if let Ok(report) = guard.report().build() {
let file = std::fs::File::create("flamegraph.svg").unwrap();
report.flamegraph(file).unwrap();
};
}
fn generate(n: usize) {
let mut count = 0;
for _ in Cubes::new(n) {
count += 1;
}
println!("{}", count);
}