Skip to content

Commit

Permalink
Also benchmark HCubature rules
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeingold committed Dec 19, 2024
1 parent bbb6fd6 commit b37cff0
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ end
spec = (
f = p -> norm(to(p)),
f_exp = p::Point -> exp(-norm(to(p))^2 / u"m^2"),
g = (
geometries = (
bezier = BezierCurve([Point(t, sin(t), 0) for t in range(-pi, pi, length = 361)]),
line = Line(Point(0, 0, 0), Point(1, 1, 1)),
plane = Plane(Point(0, 0, 0), Vec(0, 0, 1)),
ray = Ray(Point(0, 0, 0), Vec(0, 0, 1)),
rope = Rope([Point(t, t, t) for t in 1:32]...),
triangle = Triangle(Point(1, 0, 0), Point(0, 1, 0), Point(0, 0, 1)),
tetrahedron = let
Expand All @@ -56,19 +53,25 @@ spec = (
Tetrahedron(a, b, c, a + ẑ)
end
),
rule_gl = GaussLegendre(100),
rule_gk = GaussKronrod(),
rule_hc = HAdaptiveCubature()
geometries_exp = (
line = Line(Point(0, 0, 0), Point(1, 1, 1)),
plane = Plane(Point(0, 0, 0), Vec(0, 0, 1)),
ray = Ray(Point(0, 0, 0), Vec(0, 0, 1))
),
rules = (
( name = "GaussLegendre", rule = GaussLegendre(100) ),
( name = "HAdaptiveCubature", rule = HAdaptiveCubature() )
)
)

SUITE["Specializations/Scalar GaussLegendre"] = let s = BenchmarkGroup()
s["BezierCurve"] = @benchmarkable integral($spec.f, $spec.g.bezier, $spec.rule_gl)
s["Line"] = @benchmarkable integral($spec.f_exp, $spec.g.line, $spec.rule_gl)
s["Plane"] = @benchmarkable integral($spec.f_exp, $spec.g.plane, $spec.rule_gl)
s["Ray"] = @benchmarkable integral($spec.f_exp, $spec.g.ray, $spec.rule_gl)
s["Rope"] = @benchmarkable integral($spec.f, $spec.g.rope, $spec.rule_gl)
s["Triangle"] = @benchmarkable integral($spec.f, $spec.g.triangle, $spec.rule_gl)
s["Tetrahedron"] = @benchmarkable integral($spec.f, $spec.g.tetrahedron, $spec.rule_gl)
SUITE["Specializations"] = let s = BenchmarkGroup()
s[]
for r in spec.rules, geometry in spec.geometries
s[geometry.name, r.name] = @benchmarkable integral($spec.f, geometry, r.rule)
end
for r in spec.rules, geometry in spec.geometries_exp
s[geometry.name, r.name] = @benchmarkable integral($spec.f_exp, geometry, r.rule)
end
s
end

Expand Down

0 comments on commit b37cff0

Please sign in to comment.