From 603645bea04ce068448619bc9e3729adbc8c8fb0 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Thu, 10 Apr 2025 08:36:08 +0200 Subject: [PATCH 1/2] Add ordering benchmarks --- benchmark/benchmarks.jl | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index abff6d2b..9f9bfb5a 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -1,6 +1,7 @@ using BenchmarkTools using LinearAlgebra using SparseMatrixColorings +import SparseMatrixColorings as SMC using SparseArrays using StableRNGs @@ -29,13 +30,13 @@ for structure in [:nonsymmetric, :symmetric], results = [coloring(A, problem, algo; decompression_eltype=Float64) for A in As] Bs = [compress(Float64.(A), result) for (A, result) in zip(As, results)] - SUITE[:coloring][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable begin + bench_col = @benchmarkable begin for A in $As coloring(A, $problem, $algo) end end - SUITE[:decompress][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable begin + bench_dec = @benchmarkable begin for (B, result) in zip($Bs, $results) if B isa AbstractMatrix decompress(B, result) @@ -44,4 +45,34 @@ for structure in [:nonsymmetric, :symmetric], end end end + + SUITE[:coloring][structure][partition][decompression]["n=$n"]["p=$p"] = bench_col + SUITE[:decompress][structure][partition][decompression]["n=$n"]["p=$p"] = bench_dec +end + +for structure in [:nonsymmetric, :symmetric], + order in [LargestFirst(), SmallestLast(), IncidenceDegree(), DynamicLargestFirst()], + n in [10^3, 10^5], + p in [2 / n, 5 / n, 10 / n] + + nb_samples = 5 + As = [sparse(Symmetric(sprand(StableRNG(i), Bool, n, n, p))) for i in 1:nb_samples] + if structure == :symmetric + gs = [SMC.AdjacencyGraph(A) for A in As] + bench_ord = @benchmarkable begin + for g in $gs + SMC.vertices(g, $order) + end + end + else + gs = [SMC.BipartiteGraph(A) for A in As] + bench_ord = @benchmarkable begin + for g in $gs + SMC.vertices(g, Val(1), $order) + SMC.vertices(g, Val(2), $order) + end + end + end + + SUITE[:order][structure][string(order)]["n=$n"]["p=$p"] = bench_ord end From bf4a6c2eac086224eef4ec9c087d6b049506a6d4 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Thu, 10 Apr 2025 08:47:43 +0200 Subject: [PATCH 2/2] Split row and column --- benchmark/benchmarks.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 9f9bfb5a..e77fad58 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -51,6 +51,7 @@ for structure in [:nonsymmetric, :symmetric], end for structure in [:nonsymmetric, :symmetric], + partition in (structure == :nonsymmetric ? [:column, :row] : [:column]), order in [LargestFirst(), SmallestLast(), IncidenceDegree(), DynamicLargestFirst()], n in [10^3, 10^5], p in [2 / n, 5 / n, 10 / n] @@ -66,13 +67,12 @@ for structure in [:nonsymmetric, :symmetric], end else gs = [SMC.BipartiteGraph(A) for A in As] + valside = partition == :row ? Val(1) : Val(2) bench_ord = @benchmarkable begin for g in $gs - SMC.vertices(g, Val(1), $order) - SMC.vertices(g, Val(2), $order) + SMC.vertices(g, $valside, $order) end end end - - SUITE[:order][structure][string(order)]["n=$n"]["p=$p"] = bench_ord + SUITE[:order][structure][partition][string(order)]["n=$n"]["p=$p"] = bench_ord end