From 181261beefe8b709d8081b49f98fa5fd8efdc24c Mon Sep 17 00:00:00 2001 From: Ben Schofield Date: Tue, 22 Aug 2023 07:56:24 -0700 Subject: [PATCH] Add samply to sampling options Add samply to the sampling options for `rm` benchmarking. --- src/uu/rm/BENCHMARKING.md | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/uu/rm/BENCHMARKING.md b/src/uu/rm/BENCHMARKING.md index ee524cb24..4170e2df1 100644 --- a/src/uu/rm/BENCHMARKING.md +++ b/src/uu/rm/BENCHMARKING.md @@ -33,7 +33,24 @@ hyperfine --prepare "cp -r $test_dir tmp_d" "rm -rf tmp_d" "target/release/core - Another thing to look at would be system calls count using strace (on linux) or equivalent on other operating systems. - Example: `strace -c target/release/coreutils rm -rf tree` -## Cargo Flamegraph +## Flamegraphs + +### Samply + +Samply is one option for simply creating flamegraphs. It isues the Firefox profiler as a UI. + +To install: +```bash +cargo install samply +``` + +To run: + +```bash +samply record target/release/coreutils rm -rf ../linux +``` + +### Cargo Flamegraph With Cargo Flamegraph you can easily make a flamegraph of `rm`: @@ -41,12 +58,3 @@ With Cargo Flamegraph you can easily make a flamegraph of `rm`: cargo flamegraph --cmd coreutils -- rm [additional parameters] ``` -However, if the `-r` option is given, the output becomes pretty much useless due to recursion. We can fix this by merging all the direct recursive calls with `uniq`, below is a `bash` script that does this. - -```shell -#!/bin/bash -cargo build --release --no-default-features --features rm -perf record target/release/coreutils rm "$@" -perf script | uniq | inferno-collapse-perf | inferno-flamegraph > flamegraph.svg -``` -