Skip to content

Commit fae169d

Browse files
committed
use callgrind for estimating cycles
...I expect this will be extremely slow for the slower langs, since even just using this with assembly can take quite some time!
1 parent fae1af8 commit fae169d

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ results/*.json
99
*.o
1010
*.exe
1111
*.hi
12+
*.txt
1213
count
1314
java/
1415
kotlin/
@@ -18,6 +19,7 @@ CMD
1819
VERSION
1920
STATS
2021
SIZE
22+
CYCLES
2123
rss.txt
2224
GPATH
2325
GRTAGS

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/London"
44

55
RUN apt-get update
66
RUN apt-get install -y bc build-essential curl gdb lldb git jq moreutils tar \
7-
unzip wget xz-utils && apt-get clean
7+
unzip wget xz-utils valgrind && apt-get clean
88
RUN apt-get install -y clang && apt-get clean
99
RUN apt-get install -y default-jdk default-jre && apt-get clean
1010
RUN apt-get install -y erlang && apt-get clean

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +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+
valgrind --tool=callgrind --callgrind-out-file=callgrind.txt $(cat CMD)
104+
grep "summary:" callgrind.txt | awk '{print $2}' > CYCLES
105+
jq '. += {"cycles": '$(cat CYCLES)'}' "$out" | sponge "$out"
106+
103107
measure-all:
104108
#!/usr/bin/env bash
105109
set -exuo pipefail

scripts/summary.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ ${markdownTable(
107107
108108
> - <sup>1</sup>: only includes compiled files (i.e., does not include runtimes or libraries required for execution)
109109
110+
${markdownTable(
111+
[
112+
['name', 'estimated cycles'],
113+
...results
114+
.slice()
115+
.sort((a, b) => a.cycles - b.cycles)
116+
.map(({ name, cycles }) => [name, cycles]),
117+
],
118+
{
119+
align: ['l', 'r', 'l'],
120+
}
121+
)}
122+
123+
Note that cycles are counted with valgrind (using callgrind) and are only estimates of the actual CPU cycles used.
124+
125+
110126
${markdownTable(
111127
[
112128
['name', 'command', 'version'],

0 commit comments

Comments
 (0)