/ concept-collection / qhull-wasm-demo
Sign in
concept-collection / qhull-wasm-demo
qhull-wasm-demo / scripts / qhull_benchmark.m
30 lines · 984 BBlameHistoryRaw
1% qhull_benchmark.m
2%
3% Times Delaunay triangulation of uniform random points in 2D and 3D.
4% MATLAB, Octave, and numbl all compute delaunayn via Qhull, so this is a
5% direct, apples-to-apples comparison with the qhull-wasm benchmark running
6% in the browser (https://concept-collection.github.io/qhull-wasm-demo/).
7%
8% Run with: matlab -batch qhull_benchmark | octave qhull_benchmark.m
9% numbl run qhull_benchmark.m
11% Note: native and browser runs use different random points, but the timing
12% is dominated by N and dimension, not the specific sample, so totals compare.
14sizes = [1000 5000 20000 50000];
16fprintf('Qhull Delaunay benchmark\n');
17fprintf('%-8s %12s %12s\n', 'N', '2D (ms)', '3D (ms)');
18fprintf('%s\n', repmat('-', 1, 34));
20for k = 1:numel(sizes)
21 n = sizes(k);
23 P2 = rand(n, 2);
24 t = tic; delaunayn(P2); ms2 = toc(t) * 1000;
26 P3 = rand(n, 3);
27 t = tic; delaunayn(P3); ms3 = toc(t) * 1000;
29 fprintf('%-8d %12.1f %12.1f\n', n, ms2, ms3);
30end
moveopenescclose