Skip to content

Commit

Permalink
fix bench_highvor.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
axsk committed Oct 30, 2023
1 parent 36052db commit 2d43b5d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion scripts/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ version = "0.4.9"

[[deps.HighVoronoi]]
deps = ["Crayons", "Distributed", "GLPK", "IterTools", "IterativeSolvers", "JLD2", "LinearAlgebra", "NearestNeighbors", "Polyhedra", "Printf", "SparseArrays", "SpecialFunctions", "StaticArrays"]
git-tree-sha1 = "9d8e6536a920092cb44e6a37946f2521a9e3bbc2"
path = "/home/htc/bzfsikor/.julia/dev/HighVoronoi"
uuid = "1d30c219-805f-47bd-9cb8-33f291c94a4c"
version = "1.0.2"

Expand Down
47 changes: 28 additions & 19 deletions scripts/bench_highvor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,36 @@ using BenchmarkTools
using HighVoronoi
using VoronoiGraph
using MiniQhull
using Plots

suite = BenchmarkGroup()
function benchsuite(limit=7)
suite = BenchmarkGroup()

f(x) = [sum(x .^ 2)]
f1(x) = sum(x .^ 2)
f(x) = [sum(x .^ 2)]
f1(x) = sum(x .^ 2)

for dim in [2, 6]
for n in [100, 300, 1_000, 3_000, 10_000, 30_000, 100_000, 300_000]
log10(n) + dim > 9.5 && continue
local xs = HighVoronoi.VoronoiNodes(rand(dim, n))
suite[(dim, n)] = BenchmarkGroup(["($dim, $n)"])
for dim in [2, 6]
for n in [100, 300, 1_000, 3_000, 10_000, 30_000, 100_000, 300_000]
log10(n) + dim > limit && continue
local xs = HighVoronoi.VoronoiNodes(rand(dim, n))
suite[(dim, n)] = BenchmarkGroup(["($dim, $n)"])

suite[(dim, n)]["HighVoronoi"] = @benchmarkable HighVoronoi.VoronoiGeometry($xs, Boundary(), silence=true)
suite[(dim, n)]["VoronoiGraph"] = @benchmarkable VoronoiGraph.voronoi($xs)
suite[(dim, n)]["qHull"] = @benchmarkable delaunay($xs)
suite[(dim, n)]["HighVoronoi"] = @benchmarkable HighVoronoi.VoronoiGeometry($xs, Boundary(), silence=true)
suite[(dim, n)]["VoronoiGraph"] = @benchmarkable VoronoiGraph.voronoi($xs)
suite[(dim, n)]["qHull"] = @benchmarkable delaunay($xs)

suite[(dim, n)]["HighVoronoi MC"] = @benchmarkable VoronoiGeometry($xs, Boundary(), integrator=VI_MONTECARLO, integrand=f, mc_accurate=(10, 10, 20), silence=true)
suite[(dim, n)]["VoronoiGraph MC"] = @benchmarkable begin
v = voronoi($xs)
mc_integrate(f1, v[1], $xs, 10, 10)
suite[(dim, n)]["HighVoronoi MC"] = @benchmarkable VoronoiGeometry($xs, Boundary(), integrator=VI_MONTECARLO, integrand=$f, mc_accurate=(10, 10, 20), silence=true)
suite[(dim, n)]["VoronoiGraph MC"] = @benchmarkable begin
v = voronoi($xs)
mc_integrate($f1, v[1], $xs, 10, 10)
end
end
end
return suite
end

#=
function time_mc(dim=4, n=20000)
ns = VoronoiNodes(rand(dim, n))
@time VoronoiGeometry(ns, Boundary(), integrator=VI_MONTECARLO, integrand=f, mc_accurate=(10, 10, 20), silence=true)
Expand All @@ -45,6 +51,7 @@ end
sort(collect(r), by=first)
=#
#=
julia> sort(collect(r), by=first)
20-element Vector{Pair{Tuple{Int64, Int64}, Float64}}:
Expand All @@ -70,7 +77,7 @@ julia> sort(collect(r), by=first)
(6, 1000) => 3.3487722004773985
=#

methods_int = ["HighVoronoi MC", "VoronoiGraph MC"]
#methods_int = ["HighVoronoi MC", "VoronoiGraph MC"]

dimkeys(r, d) = sort(collect(keys(filter(r) do pair
pair[1][1] == d
Expand Down Expand Up @@ -116,8 +123,10 @@ function plotperf(r; d=2, methods=["qHull", "HighVoronoi", "VoronoiGraph"], kwar
#savefig("perf.pdf")
end

function run()
r = @time BenchmarkTools.run(suite)
plotperf(r, marker=:o, markersize=2)
function runplots(r=BenchmarkTools.run(benchsuite()))
plotperf(r, marker=:o, markersize=2) |> display
return r
end

# TO RUN THE BENCHMARKS:
#run(benchsuite())

1 comment on commit 2d43b5d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Julia benchmark result

Benchmark suite Current: 2d43b5d Previous: e4b0fac Ratio
2/100 330017 ns 368703 ns 0.90
2/1000 4227127 ns 3704629 ns 1.14
3/100 1258268 ns 1155710 ns 1.09
3/1000 19862863 ns 17058748 ns 1.16
4/100 5290683.5 ns 4754437 ns 1.11
4/1000 127221393 ns 113580391 ns 1.12
5/100 23618807.5 ns 20699776 ns 1.14
5/1000 931626899.5 ns 823220794 ns 1.13

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.