Skip to content

Commit fae141a

Browse files
committed
switch to perf since callgrind had issues
1 parent fae165d commit fae141a

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ scala/
1818
scripts/summary.md
1919
CMD
2020
VERSION
21+
INSTRUCTIONS
2122
STATS
2223
SIZE
2324
CYCLES

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/London"
44

55
RUN apt-get update
66
RUN apt-get install -y autoconf automake bc bison build-essential curl flex \
7-
gawk gdb git jq libffi-dev libsigsegv-dev libtool lldb moreutils pkg-config \
8-
tar texinfo unzip valgrind wget xz-utils zip && apt-get clean
7+
gawk gdb git jq libffi-dev libsigsegv-dev libtool linux-perf lldb moreutils \
8+
pkg-config tar texinfo unzip wget xz-utils zip && apt-get clean
99
RUN apt-get install -y clang && apt-get clean
1010
RUN apt-get install -y default-jdk default-jre && apt-get clean
1111
RUN apt-get install -y erlang && apt-get clean

justfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ _all:
3939
just -l | grep -v 'build-all' | grep 'build-' | cut -d'-' -f2- | xargs
4040

4141
build what:
42-
rm -f CMD VERSION STATS SIZE CYCLES
42+
rm -f CMD VERSION STATS SIZE CYCLES INSTRUCTIONS
4343
just build-{{what}}
4444

4545
build-all:
@@ -100,11 +100,10 @@ measure what: (_check "bc hyperfine max_rss jq sponge")
100100
max_rss -ro STATS -- $(cat CMD)
101101
jq '. += {"max_rss": '$(cat STATS)'}' "$out" | sponge "$out"
102102

103-
cycle_cmd="$(cat CMD)"
104-
cycle_cmd="${cycle_cmd/{{i}}/100000}"
105-
valgrind --tool=callgrind --callgrind-out-file=callgrind.txt $cycle_cmd
106-
grep "summary:" callgrind.txt | awk '{print $2}' > CYCLES
107-
jq '. += {"cycles": '$(cat CYCLES)'}' "$out" | sponge "$out"
103+
perf_out=$(perf stat -x, -e cycles,instructions $(cat CMD) 2>&1 >/dev/null)
104+
echo "$perf_out" | awk -F, '$3~/^cycles/{print $1}' > CYCLES
105+
echo "$perf_out" | awk -F, '$3~/^instructions/{print $1}' > INSTRUCTIONS
106+
jq '. += {"cycles": '$(cat CYCLES)',"instructions": '$(cat INSTRUCTIONS)'}' "$out" | sponge "$out"
108107

109108
measure-all:
110109
#!/usr/bin/env bash

scripts/summary.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ ${markdownTable(
120120
}
121121
)}
122122
123-
Note that cycles are counted with valgrind (using callgrind) and are only estimates of the actual CPU cycles used.
124-
Called with \`100000\` as input.
123+
Note that cycles are counted with \`perf\` and are only estimates of the actual CPU cycles used, as this can vary.
125124
126125
${markdownTable(
127126
[

0 commit comments

Comments
 (0)