Skip to content

Add a benchmark script to compare speed and output between builds - #114

Open
clintmorris229 wants to merge 1 commit into
SarahWeiii:mainfrom
clintmorris229:add-benchmark-script
Open

clintmorris229 wants to merge 1 commit into
SarahWeiii:mainfrom
clintmorris229:add-benchmark-script

Conversation

@clintmorris229

Copy link
Copy Markdown
Contributor

This adds run_benchmark.py, a small script for measuring CoACD's speed and checking that a change doesn't alter its results. It's meant as a first step before a few small performance PRs, so each one can show its numbers the same way.

It runs the main executable on the example meshes with a fixed seed (0 by default, since main otherwise seeds from the clock). For each mesh it reports the median wall time over several runs, how much the run times vary, the number of hulls and a SHA-256 of the output OBJ. With --baseline and --candidate it alternates runs of the two builds, so changes in machine load affect both alike. It prints the speedup and whether the outputs are identical, and exits with an error if any differ. It uses only the Python standard library and doesn't change any C++ or CMake files. A short section in the README explains how to use it.

Comparing main with a second copy of itself, 3 runs each on an otherwise idle machine (Linux, Release, OpenMP), shows how much noise there is:

mesh                  baseline s   +-%  candidate s   +-%  speedup  hulls  identical
Bottle                     46.89   0.4        46.98   0.6    1.00x    115  yes
Kettle                     35.76   0.3        35.83   0.3    1.00x     79  yes
KitchenPot                 23.74   0.8        23.62   0.2    1.01x     47  yes
Octocat-v2                 24.97   0.2        25.03   0.3    1.00x     62  yes
SnowFlake                   6.53   1.3         6.53   1.3    1.00x     47  yes
total                     137.89             137.99          1.00x

So on a quiet machine, speedups above about 1% are measurable. The +-% columns give the variation for each comparison. The identity check compares the OBJ files that main writes, which store coordinates with 6 significant digits.

run_benchmark.py runs the main executable on the example meshes with a fixed seed and reports the median time, how much the run times vary, the number of hulls and a hash of the output for each mesh. Given a second executable, it alternates runs of the two and reports the speedup and whether the outputs are identical.
@clintmorris229
clintmorris229 marked this pull request as ready for review November 24, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant