Skip to content

Commit e7a6aef

Browse files
committed
add benchmarks, closes #23
1 parent a3cbda0 commit e7a6aef

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

bench/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
params.json

bench/benchmark.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using BenchmarkTools
2+
using Meshing
3+
using GeometryTypes
4+
5+
# Define a parent BenchmarkGroup to contain our suite
6+
const suite = BenchmarkGroup()
7+
8+
println("Benchmarking Meshing.jl...")
9+
10+
algos = [MarchingCubes(), MarchingTetrahedra(), NaiveSurfaceNets()]
11+
12+
torus = SignedDistanceField(HyperRectangle(Vec(-2,-2,-2.),Vec(4,4,4.)),0.05) do v
13+
(sqrt(v[1]^2+v[2]^2)-0.5)^2 + v[3]^2 - 0.25 # torus
14+
end
15+
16+
for algo in algos
17+
suite[string(typeof(algo))] = @benchmarkable HomogenousMesh(torus, $algo)
18+
end
19+
20+
# If a cache of tuned parameters already exists, use it, otherwise, tune and cache
21+
# the benchmark parameters. Reusing cached parameters is faster and more reliable
22+
# than re-tuning `suite` every time the file is included.
23+
paramspath = joinpath(dirname(@__FILE__), "params.json")
24+
25+
if isfile(paramspath)
26+
loadparams!(suite, BenchmarkTools.load(paramspath)[1], :evals);
27+
else
28+
tune!(suite)
29+
BenchmarkTools.save(paramspath, params(suite));
30+
end
31+
32+
results = run(suite)
33+
for trial in results
34+
ctx = IOContext(stdout, :verbose => true, :compact => false)
35+
println(ctx)
36+
println(ctx, trial.first)
37+
println(ctx, trial.second)
38+
end

bench/profile.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Meshing
2+
using GeometryTypes
3+
using Juno
4+
using Profile
5+
6+
7+
algo = NaiveSurfaceNets()
8+
9+
torus = SignedDistanceField(HyperRectangle(Vec(-2,-2,-2.),Vec(4,4,4.)),0.05) do v
10+
(sqrt(v[1]^2+v[2]^2)-0.5)^2 + v[3]^2 - 0.25 # torus
11+
end
12+
13+
m2 = HomogenousMesh(torus, algo)
14+
15+
Profile.clear()
16+
Juno.@profiler HomogenousMesh(torus, algo)
17+
18+
Juno.profiler()

0 commit comments

Comments
 (0)