profiling 4

master
Andrew Johnson 6 years ago
parent 1569c8d567
commit 5274268104

@ -3,7 +3,6 @@ name = "Chapter9"
version = "1.0.0"
[dependencies]
cpuprofiler = "0.0.2"
flame = "0.2"
rand = "0.4.2"
@ -30,3 +29,7 @@ path = "performance_profiling2.rs"
[[bin]]
name = "performance_profiling3"
path = "performance_profiling3.rs"
[[bin]]
name = "performance_profiling4"
path = "performance_profiling4.rs"

@ -1,4 +1,4 @@
This chapter makes use of Google's [cpuprofiler](http://goog-perftools.sourceforge.net/doc/cpu_profiler.html),
which needs to be installed separately. It will not be installed through the normal cargo build process.
This chapter makes use of Cargo Profiler and valgrind.
They will not be installed through the normal cargo build process and need separate installation.
[GPerftools](https://github.com/gperftools/gperftools) is also available on Github.
[Cargo Profiler](https://github.com/kernelmachine/cargo-profiler) installation instructions are available on Github.

@ -0,0 +1,23 @@
fn a(n: u64) -> u64 {
if n>0 {
b(n);
b(n);
}
n * n
}
fn b(n: u64) -> u64 {
c(n);
c(n);
n + 2 / 3
}
fn c(n: u64) -> u64 {
a(n-1);
a(n-1);
vec![1, 2, 3].into_iter().map(|x| x+2).sum()
}
fn main() {
a(6);
}
Loading…
Cancel
Save