Skip to content

Instantly share code, notes, and snippets.

@ochafik
Last active May 27, 2023 14:18
Show Gist options
  • Select an option

  • Save ochafik/fa0b475dbc719bb64f26d5703ac32bc0 to your computer and use it in GitHub Desktop.

Select an option

Save ochafik/fa0b475dbc719bb64f26d5703ac32bc0 to your computer and use it in GitHub Desktop.
OpenSCAD branches benchmark script for https://github.com/openscad/openscad/pull/4654

Results

binstl

sphere_1000.scad → binstl

Branch Mean [ms] Min [ms] Max [ms] Relative
fast-integ 198.0 ± 7.2 189.1 213.2 1.01 ± 0.04
master 536.5 ± 14.6 517.9 559.6 2.72 ± 0.10
fast-stl3 197.0 ± 4.9 191.6 205.2 1.00
identifiers 541.9 ± 15.0 525.9 566.8 2.75 ± 0.10
vector-reserve 536.0 ± 15.1 516.7 560.4 2.72 ± 0.10
polyset-reserve 457.0 ± 10.4 441.9 476.1 2.32 ± 0.08
virtual-simplify 542.8 ± 15.4 521.6 566.7 2.76 ± 0.10
remove-dupe-vars 539.7 ± 17.6 517.5 559.2 2.74 ± 0.11
frame-reserve 534.8 ± 11.4 522.8 555.8 2.71 ± 0.09

2_spheres_1000.scad → binstl

Branch Mean [ms] Min [ms] Max [ms] Relative
fast-integ 35.9 ± 0.9 35.0 37.2 1.04 ± 0.04
master 37.2 ± 1.7 35.2 40.2 1.07 ± 0.06
fast-stl3 35.1 ± 0.5 34.6 36.3 1.01 ± 0.03
identifiers 36.0 ± 1.1 34.8 38.2 1.04 ± 0.04
vector-reserve 34.6 ± 1.0 33.5 36.8 1.00
polyset-reserve 35.1 ± 0.6 34.4 36.1 1.01 ± 0.03
virtual-simplify 35.7 ± 1.1 34.6 37.9 1.03 ± 0.04
remove-dupe-vars 35.6 ± 1.0 34.5 37.7 1.03 ± 0.04
frame-reserve 35.4 ± 0.5 34.8 36.5 1.02 ± 0.03

poly_attached_inlined.scad -Dsingle=true → binstl

Branch Mean [s] Min [s] Max [s] Relative
fast-integ 8.250 ± 0.035 8.205 8.301 1.00
master 10.263 ± 0.023 10.242 10.319 1.24 ± 0.01
fast-stl3 10.248 ± 0.061 10.151 10.379 1.24 ± 0.01
identifiers 8.636 ± 0.105 8.521 8.806 1.05 ± 0.01
vector-reserve 10.000 ± 0.025 9.961 10.041 1.21 ± 0.01
polyset-reserve 10.551 ± 0.052 10.441 10.606 1.28 ± 0.01
virtual-simplify 10.355 ± 0.128 10.221 10.573 1.26 ± 0.02
remove-dupe-vars 10.289 ± 0.045 10.215 10.361 1.25 ± 0.01
frame-reserve 10.284 ± 0.054 10.222 10.389 1.25 ± 0.01

poly_attached_inlined.scad -Dsingle=false → binstl

Branch Mean [s] Min [s] Max [s] Relative
fast-integ 36.235 ± 0.267 35.850 36.678 1.00
master 44.791 ± 0.362 44.165 45.306 1.24 ± 0.01
fast-stl3 44.468 ± 0.290 44.046 44.878 1.23 ± 0.01
identifiers 38.025 ± 0.260 37.607 38.465 1.05 ± 0.01
vector-reserve 43.755 ± 0.225 43.335 44.084 1.21 ± 0.01
polyset-reserve 44.346 ± 0.167 44.114 44.641 1.22 ± 0.01
virtual-simplify 44.900 ± 0.248 44.517 45.271 1.24 ± 0.01
remove-dupe-vars 45.006 ± 0.267 44.632 45.532 1.24 ± 0.01
frame-reserve 45.127 ± 0.552 44.576 46.167 1.25 ± 0.02

golden_heart_cage.scad → binstl

Branch Mean [s] Min [s] Max [s] Relative
fast-integ 6.402 ± 0.036 6.355 6.471 1.00
master 7.447 ± 0.061 7.414 7.618 1.16 ± 0.01
fast-stl3 7.220 ± 0.013 7.188 7.233 1.13 ± 0.01
identifiers 6.783 ± 0.013 6.764 6.809 1.06 ± 0.01
vector-reserve 7.292 ± 0.031 7.234 7.347 1.14 ± 0.01
polyset-reserve 7.251 ± 0.027 7.193 7.283 1.13 ± 0.01
virtual-simplify 7.354 ± 0.065 7.318 7.536 1.15 ± 0.01
remove-dupe-vars 7.363 ± 0.017 7.341 7.391 1.15 ± 0.01
frame-reserve 7.351 ± 0.018 7.333 7.378 1.15 ± 0.01

asciistl

sphere_1000.scad → asciistl

Branch Mean [s] Min [s] Max [s] Relative
master 4.218 ± 0.078 4.152 4.397 5.66 ± 0.15
fast-stl3 0.746 ± 0.015 0.729 0.771 1.00

asciistl

golden_heart_cage.scad → asciistl

Branch Mean [s] Min [s] Max [s] Relative
master 7.809 ± 0.014 7.789 7.835 1.08 ± 0.01
fast-stl3 7.212 ± 0.040 7.166 7.309 1.00

echo

golden_heart_cage.scad → echo

Branch Mean [ms] Min [ms] Max [ms] Relative
fast-integ 700.5 ± 13.3 688.5 734.0 1.00
master 781.1 ± 6.8 773.7 794.5 1.12 ± 0.02
fast-stl3 787.4 ± 14.6 776.8 820.0 1.12 ± 0.03
identifiers 720.4 ± 11.4 708.9 744.7 1.03 ± 0.03
vector-reserve 770.5 ± 6.3 762.4 783.1 1.10 ± 0.02
polyset-reserve 780.2 ± 7.3 774.2 797.9 1.11 ± 0.02
virtual-simplify 792.2 ± 9.1 781.0 805.8 1.13 ± 0.03
remove-dupe-vars 792.7 ± 8.6 779.8 807.8 1.13 ± 0.02
frame-reserve 779.6 ± 5.0 773.4 791.3 1.11 ± 0.02
#!/bin/bash
#
# Example:
# ../bench.sh ../{sphere_1000,2_spheres_1000}.scad "../poly_attached_inlined.scad -Dsingle=true" "../poly_attached_inlined.scad -Dsingle=false"
#
#
set -euo pipefail
# Times each file is run in each mode / branch
RUNS=${RUNS:-10}
# Parallelism (don't put more here than you have virtual cores)
N=${N:-10}
# Relative path of the binary inside the build folder. This default is for MacOS.
BINARY=${BINARY:-OpenSCAD.app/Contents/MacOS/OpenSCAD}
# Pass list of files as arguments
FILES=( "$@" )
BRANCHES=(
fast-integ
master
fast-stl3
identifiers
vector-reserve
polyset-reserve
virtual-simplify
remove-dupe-vars
frame-reserve
)
FORMATS=(
binstl
asciistl
echo
)
function join_by {
local IFS="$1"
shift
echo "$*"
}
function build_branch() {
local branch="$1"
echo "# Building branch $branch"
git checkout $branch
git pull
mkdir -p build-$branch
cd build-$branch
if [[ ! -f Makefile || ../CMakeLists.txt -nt Makefile ]]; then
cmake -DCMAKE_BUILD_TYPE=Release -DEXPERIMENTAL=1 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=1 ..
fi
make -j${N}
}
if [[ "${BUILD:-1}" == 1 ]]; then
for branch in "${BRANCHES[@]}" ; do
( build_branch "$branch" )
done
fi
TIMESTAMP=$( gdate '+%Y%m%d-%H%M' )
echo "# Results" > bench-results-${TIMESTAMP}.md
for format in "${FORMATS[@]}" ; do
echo "
## ${format}
" >> bench-results-${TIMESTAMP}.md
for file in "${FILES[@]}" ; do
filename=$(basename -- "$file")
filenamestem=$(echo "$filename" | sed -E 's/[^a-zA-Z0-9]+/_/g' )
branches=()
for branch in "${BRANCHES[@]}" ; do
if [[ "$format" == "asciistl" ]]; then
if [[ "$branch" == *stl* || "$branch" == master ]]; then
branches+=( "$branch" )
fi
else
branches+=( "$branch" )
fi
done
echo "
### ${filename} → ${format}
" >> bench-results-${TIMESTAMP}.md
hyperfine_args=(
-i
-L branch "$( join_by , "${branches[@]}" )"
# -L format "binstl,asciistl,echo"
# -L file "$( join_by , "${FILES[@]}" )"
--warmup 1
--runs "$RUNS"
--export-json "bench-results-${TIMESTAMP}-${filenamestem}-${format}.json"
--export-markdown "bench-results-${TIMESTAMP}-${filenamestem}-${format}.md"
"./build-{branch}/${BINARY} ${file} -o out --export-format=${format} --enable=manifold"
)
echo "# Rendering ${file} to format ${format} with ${#branches[@]} branches: $( join_by , "${branches[@]}" )"
hyperfine "${hyperfine_args[@]}"
cat "bench-results-${TIMESTAMP}-${filenamestem}-${format}.md" >> bench-results-${TIMESTAMP}.md
done
done
sed -E -i.bak 's/`.\/build-([^/]+)[^`]+`/\1/g' bench-results-${TIMESTAMP}.md
sed -E -i.bak 's/\| Command \|/| Branch |/g' bench-results-${TIMESTAMP}.md
echo "
bench-results-${TIMESTAMP}.md
"
# hyperfine_args=(
# -i
# -L branch "$( join_by , "${BRANCHES[@]}" )"
# -L format "binstl,asciistl,echo"
# -L file "$( join_by , "${FILES[@]}" )"
# --warmup 1
# --runs "$RUNS"
# --export-json "bench-results-${TIMESTAMP}.json"
# --export-markdown "bench-results-${TIMESTAMP}.md"
# "./build-{branch}/${BINARY} {file} -o out --export-format={format} --enable=manifold"
# )
# hyperfine "${hyperfine_args[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment