From fae1579cb51c2de3a830b42a6aafad1e493c7c8a Mon Sep 17 00:00:00 2001 From: acheronfail Date: Thu, 11 Jan 2024 15:05:35 +1030 Subject: [PATCH] add size table for binaries --- justfile | 23 +++++++++++++---------- scripts/summary.js | 21 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/justfile b/justfile index 0bacdb8..13c6814 100644 --- a/justfile +++ b/justfile @@ -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: @@ -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" @@ -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 @@ -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") diff --git a/scripts/summary.js b/scripts/summary.js index 94b8da1..df5a151 100644 --- a/scripts/summary.js +++ b/scripts/summary.js @@ -27,7 +27,8 @@ await writeFile( - + + +
Execution timeMax Memory UsageBinary sizeMax Memory Usage*
@@ -48,6 +49,23 @@ ${markdownTable( +${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'], + } +)} + + + ${markdownTable( [ ['position', 'name', 'max_rss'], @@ -61,6 +79,7 @@ ${markdownTable( } )} +