Skip to content

Commit

Permalink
add size table for binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail committed Jan 11, 2024
1 parent fae17ee commit fae1579
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
23 changes: 13 additions & 10 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ measure-all:
cd scripts && npm start

build what:
rm -f CMD VERSION
rm -f count CMD VERSION
just build-{{what}}

run what:
Expand Down Expand Up @@ -82,6 +82,9 @@ measure what:
hyperfine $args --shell=none --export-json "$out" "$(cat CMD)"
jq '.results[0] | del(.exit_codes)' "$out" | sponge "$out"
jq '. += {"name":"{{what}}","version":"'"$(cat VERSION)"'"}' "$out" | sponge "$out"
if [ -x count ]; then
jq '. += {"size":'"$(stat -c '%s' count)"'}' "$out" | sponge "$out"
fi
timers $(cat CMD) >/dev/null 2> STATS
jq '. += {"max_rss":'$(rg -oP '(?:max_rss:\s*)(\d+)' -r '$1' ./STATS)'}' "$out" | sponge "$out"

Expand Down Expand Up @@ -127,23 +130,23 @@ test what:

build-c-gcc: (_check "gcc")
gcc --version | head -1 > VERSION
gcc -O3 ./count.c
echo './a.out {{i}}' > CMD
gcc -O3 -o count ./count.c
echo './count {{i}}' > CMD

build-c-clang: (_check "clang")
clang --version | head -1 > VERSION
clang -O3 ./count.c
echo './a.out {{i}}' > CMD
clang -O3 -o count ./count.c
echo './count {{i}}' > CMD

build-cpp-gcc: (_check "g++")
g++ --version | head -1 > VERSION
g++ -O3 ./count.cpp
echo './a.out {{i}}' > CMD
g++ -O3 -o count ./count.cpp
echo './count {{i}}' > CMD

build-cpp-clang: (_check "clang++")
clang++ --version | head -1 > VERSION
clang++ -O3 ./count.cpp
echo './a.out {{i}}' > CMD
clang++ -O3 -o count ./count.cpp
echo './count {{i}}' > CMD

build-rust: (_check "rustc")
rustc --version > VERSION
Expand All @@ -152,7 +155,7 @@ build-rust: (_check "rustc")

build-fortran: (_check "gfortran")
gfortran --version | head -1 > VERSION
gfortran -O3 ./count.f90
gfortran -O3 -o count ./count.f90
echo './a.out {{i}}' > CMD

build-java: (_check "javac java")
Expand Down
21 changes: 20 additions & 1 deletion scripts/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ await writeFile(
<table>
<tr>
<th>Execution time</th>
<th>Max Memory Usage</th>
<th>Binary size</th>
<th>Max Memory Usage*</th>
</tr>
<tr>
<td>
Expand All @@ -48,6 +49,23 @@ ${markdownTable(
</td>
<td>
${markdownTable(
[
['position', 'name', 'size'],
...results
.slice()
.sort((a, b) => a.name.localeCompare(b.name))
.sort((a, b) => (a.size ?? Infinity) - (b.size ?? Infinity))
.map(({ name, size }, i) => [i + 1, wrap(name), size ? formatSize(size, { minimumFractionDigits: 7 }) : '-']),
],
{
align: ['c', 'l', 'r'],
}
)}
</td>
<td>
${markdownTable(
[
['position', 'name', 'max_rss'],
Expand All @@ -61,6 +79,7 @@ ${markdownTable(
}
)}
</td>
</tr>
</table>
Expand Down

0 comments on commit fae1579

Please sign in to comment.