From d134bc8e9ae197a2b95a2071b7a3eed6f4dce3e0 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Sun, 21 May 2023 23:37:15 -0700 Subject: [PATCH] Move profiling to a separate page in the manual --- manual/src/SUMMARY.md | 1 + manual/src/contributing.md | 28 ---------------------------- manual/src/profiling.md | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 manual/src/profiling.md diff --git a/manual/src/SUMMARY.md b/manual/src/SUMMARY.md index 01dd3a753..e03f1e297 100644 --- a/manual/src/SUMMARY.md +++ b/manual/src/SUMMARY.md @@ -13,6 +13,7 @@ - [Contributing](./contributing.md) - [Parser Vendoring](./parser_vendoring.md) - [Adding A Parser](./adding_a_parser.md) + - [Profiling](./profiling.md) - [Glossary](./glossary.md) - [Alternative Projects](./alternative_projects.md) - [Tree Diffing](./tree_diffing.md) diff --git a/manual/src/contributing.md b/manual/src/contributing.md index affe2e3c4..f18edd622 100644 --- a/manual/src/contributing.md +++ b/manual/src/contributing.md @@ -79,34 +79,6 @@ $ DFT_LOG=debug cargo run sample_files/old.jsx sample_files/new.jsx See the [`env_logger` documentation](https://docs.rs/env_logger/0.9.0/env_logger/) for full details. -## Profiling - -If you have a file that's particularly slow, you can use -[cargo-flamegraph](https://github.com/flamegraph-rs/flamegraph) to see -which functions are slow. - -``` -$ CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --bin difft sample_files/slow_before.rs sample_files/slow_after.rs -``` - -It's also worth looking at memory usage, as graph traversal bugs can -lead to huge memory consumption. - -``` -$ /usr/bin/time -v ./target/release/difft sample_files/slow_before.rs sample_files/slow_after.rs -``` - -If timing measurement are noisy, Linux's `perf` tool will report -instructions executed, which is more stable. - -``` -$ perf stat ./target/release/difft sample_files/slow_before.rs sample_files/slow_after.rs -$ perf stat ./target/release/difft sample_files/typing_old.ml sample_files/typing_new.ml -``` - -Many more profiling techniques are discussed in [The Rust Performance -Book](https://nnethercote.github.io/perf-book/). - ## Releasing Use Cargo to create a new release, and tag it in git. Difftastic has a diff --git a/manual/src/profiling.md b/manual/src/profiling.md new file mode 100644 index 000000000..00ad6c21f --- /dev/null +++ b/manual/src/profiling.md @@ -0,0 +1,27 @@ +## Profiling + +If you have a file that's particularly slow, you can use +[cargo-flamegraph](https://github.com/flamegraph-rs/flamegraph) to see +which functions are slow. + +``` +$ CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --bin difft sample_files/slow_before.rs sample_files/slow_after.rs +``` + +It's also worth looking at memory usage, as graph traversal bugs can +lead to huge memory consumption. + +``` +$ /usr/bin/time -v ./target/release/difft sample_files/slow_before.rs sample_files/slow_after.rs +``` + +If timing measurement are noisy, Linux's `perf` tool will report +instructions executed, which is more stable. + +``` +$ perf stat ./target/release/difft sample_files/slow_before.rs sample_files/slow_after.rs +$ perf stat ./target/release/difft sample_files/typing_old.ml sample_files/typing_new.ml +``` + +Many more profiling techniques are discussed in [The Rust Performance +Book](https://nnethercote.github.io/perf-book/).