Skip to content

Commit 0b29000

Browse files
committed
mem props POC
1 parent 2028242 commit 0b29000

31 files changed

+756
-340
lines changed

bench.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
3+
4+
5+
#!/bin/bash
6+
7+
# Check if at least one argument is provided
8+
if [ "$#" -lt 1 ]; then
9+
echo "Usage: $0 <application> [args...]"
10+
exit 1
11+
fi
12+
13+
# Variables
14+
APP="$1" # The application to run
15+
shift # Remove the application from the arguments list
16+
ARGS="$@" # Remaining arguments passed to the application
17+
USER="rrudnick" # The user to own the generated perf data
18+
FLAMEGRAPH_DIR="./FlameGraph" # Path to the FlameGraph repository
19+
20+
# Check if FlameGraph repository exists
21+
if [ ! -d "$FLAMEGRAPH_DIR" ]; then
22+
echo "Error: FlameGraph directory not found at $FLAMEGRAPH_DIR."
23+
echo "Clone it using: git clone https://github.com/brendangregg/FlameGraph.git"
24+
exit 1
25+
fi
26+
27+
# Run application under perf
28+
echo "Recording performance data..."
29+
sudo perf record -F 99 -g --call-graph dwarf -- "$APP" $ARGS
30+
31+
# Change ownership of the generated perf data
32+
echo "Changing ownership of perf data..."
33+
sudo chown "$USER" perf.data
34+
35+
# Process perf.data into a readable format
36+
echo "Processing perf data..."
37+
perf script > out.perf
38+
39+
# Generate folded stacks
40+
echo "Generating folded stacks..."
41+
"$FLAMEGRAPH_DIR/stackcollapse-perf.pl" out.perf > out.folded
42+
43+
# Generate the flame graph
44+
echo "Generating flame graph..."
45+
"$FLAMEGRAPH_DIR/flamegraph.pl" out.folded > flamegraph.svg
46+
47+
# Open the flame graph in Firefox
48+
echo "Opening flame graph in Firefox..."
49+
firefox flamegraph.svg &
50+
51+
echo "Done! The flame graph is saved as flamegraph.svg."
52+
53+

0 commit comments

Comments
 (0)