diff --git a/scripts/Manifest.toml b/scripts/Manifest.toml index dc54144..f1bee30 100644 --- a/scripts/Manifest.toml +++ b/scripts/Manifest.toml @@ -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" diff --git a/scripts/bench_highvor.jl b/scripts/bench_highvor.jl index 491c51c..96df901 100644 --- a/scripts/bench_highvor.jl +++ b/scripts/bench_highvor.jl @@ -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) @@ -45,6 +51,7 @@ end sort(collect(r), by=first) +=# #= julia> sort(collect(r), by=first) 20-element Vector{Pair{Tuple{Int64, Int64}, Float64}}: @@ -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 @@ -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()) \ No newline at end of file