Andrew Johnson 6 years ago
parent c30a4e35e6
commit 5c167d0f5d

@ -10,3 +10,23 @@ rand = "0.4.2"
[[bin]]
name = "performance_release_mode"
path = "performance_release_mode.rs"
[[bin]]
name = "performance_omission1"
path = "performance_omission1.rs"
[[bin]]
name = "performance_omission2"
path = "performance_omission2.rs"
[[bin]]
name = "performance_profiling1"
path = "performance_profiling1.rs"
[[bin]]
name = "performance_profiling2"
path = "performance_profiling2.rs"
[[bin]]
name = "performance_profiling3"
path = "performance_profiling3.rs"

@ -0,0 +1,21 @@
extern crate flame;
use std::fs::File;
fn main() {
let v: Vec<u64> = vec![2; 1000000];
flame::start("Iterator .collect");
let mut _z = vec![];
for _ in 0..1000 {
_z = v.iter().map(|x| x*x).collect::<Vec<u64>>();
}
flame::end("Iterator .collect");
flame::start("Iterator iterate");
for _ in 0..1000 {
v.iter().map(|x| x * x).for_each(drop);
}
flame::end("Iterator iterate");
flame::dump_html(&mut File::create("flame-graph.html").unwrap()).unwrap();
}

@ -0,0 +1,9 @@
use std::mem::forget;
fn main() {
for _ in 0..10000 {
let mut a = vec![2; 10000000];
a[2] = 2;
forget(a);
}
}
Loading…
Cancel
Save