Skip to content

Commit 71ba02b

Browse files
authored
Add ordering benchmarks (#246)
* Add ordering benchmarks * Split row and column
1 parent 744827d commit 71ba02b

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

benchmark/benchmarks.jl

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using BenchmarkTools
22
using LinearAlgebra
33
using SparseMatrixColorings
4+
import SparseMatrixColorings as SMC
45
using SparseArrays
56
using StableRNGs
67

@@ -29,13 +30,13 @@ for structure in [:nonsymmetric, :symmetric],
2930
results = [coloring(A, problem, algo; decompression_eltype=Float64) for A in As]
3031
Bs = [compress(Float64.(A), result) for (A, result) in zip(As, results)]
3132

32-
SUITE[:coloring][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable begin
33+
bench_col = @benchmarkable begin
3334
for A in $As
3435
coloring(A, $problem, $algo)
3536
end
3637
end
3738

38-
SUITE[:decompress][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable begin
39+
bench_dec = @benchmarkable begin
3940
for (B, result) in zip($Bs, $results)
4041
if B isa AbstractMatrix
4142
decompress(B, result)
@@ -44,4 +45,34 @@ for structure in [:nonsymmetric, :symmetric],
4445
end
4546
end
4647
end
48+
49+
SUITE[:coloring][structure][partition][decompression]["n=$n"]["p=$p"] = bench_col
50+
SUITE[:decompress][structure][partition][decompression]["n=$n"]["p=$p"] = bench_dec
51+
end
52+
53+
for structure in [:nonsymmetric, :symmetric],
54+
partition in (structure == :nonsymmetric ? [:column, :row] : [:column]),
55+
order in [LargestFirst(), SmallestLast(), IncidenceDegree(), DynamicLargestFirst()],
56+
n in [10^3, 10^5],
57+
p in [2 / n, 5 / n, 10 / n]
58+
59+
nb_samples = 5
60+
As = [sparse(Symmetric(sprand(StableRNG(i), Bool, n, n, p))) for i in 1:nb_samples]
61+
if structure == :symmetric
62+
gs = [SMC.AdjacencyGraph(A) for A in As]
63+
bench_ord = @benchmarkable begin
64+
for g in $gs
65+
SMC.vertices(g, $order)
66+
end
67+
end
68+
else
69+
gs = [SMC.BipartiteGraph(A) for A in As]
70+
valside = partition == :row ? Val(1) : Val(2)
71+
bench_ord = @benchmarkable begin
72+
for g in $gs
73+
SMC.vertices(g, $valside, $order)
74+
end
75+
end
76+
end
77+
SUITE[:order][structure][partition][string(order)]["n=$n"]["p=$p"] = bench_ord
4778
end

0 commit comments

Comments
 (0)