Skip to content

Commit d854aa4

Browse files
authored
Improve benchmarks, add bicoloring (take 2, less memory-hungry) (#189)
* Improve benchmarks, add bicoloring * Better deps specification * Less memory-hungry
1 parent 7253982 commit d854aa4

2 files changed

Lines changed: 31 additions & 16 deletions

File tree

.github/workflows/Benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
echo $PATH
3636
ls -l ~/.julia/bin
3737
mkdir results
38-
benchpkg ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --url=${{ github.event.repository.clone_url }} --bench-on="${{github.event.repository.default_branch}}" --output-dir=results/ --tune
38+
benchpkg ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --url=${{ github.event.repository.clone_url }} --bench-on="${{github.event.repository.default_branch}}" --output-dir=results/ --tune --add StableRNGs
3939
- name: Create markdown table from benchmarks
4040
run: |
4141
benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} --mode="time,memory" --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --input-dir=results/ --ratio > table.md

benchmark/benchmarks.jl

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,44 @@ using BenchmarkTools
22
using LinearAlgebra
33
using SparseMatrixColorings
44
using SparseArrays
5+
using StableRNGs
56

67
SUITE = BenchmarkGroup()
78

89
for structure in [:nonsymmetric, :symmetric],
9-
partition in (structure == :nonsymmetric ? [:column, :row] : [:column]),
10-
decompression in (structure == :nonsymmetric ? [:direct] : [:direct, :substitution]),
10+
partition in (structure == :nonsymmetric ? [:column, :row, :bidirectional] : [:column]),
11+
decompression in (
12+
if (structure == :nonsymmetric && partition in [:column, :row])
13+
[:direct]
14+
else
15+
[:direct, :substitution]
16+
end
17+
),
1118
n in [10^3, 10^5],
1219
p in [2 / n, 5 / n, 10 / n]
1320

1421
problem = ColoringProblem(; structure, partition)
15-
algo = GreedyColoringAlgorithm(; decompression)
22+
algo = GreedyColoringAlgorithm(; decompression, postprocessing=true)
1623

17-
SUITE[:coloring][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable coloring(
18-
A, $problem, $algo
19-
) setup = ( #
20-
A = sparse(Symmetric(sprand($n, $n, $p)))
21-
)
24+
# use several random matrices to reduce variance
25+
nb_samples = 5
26+
As = [sparse(Symmetric(sprand(StableRNG(i), Bool, n, n, p))) for i in 1:nb_samples]
27+
results = [coloring(A, problem, algo) for A in As]
28+
Bs = [compress(A, result) for (A, result) in zip(As, results)]
2229

23-
SUITE[:decompress][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable decompress(
24-
B, result
25-
) setup = ( #
26-
A = sparse(Symmetric(sprand($n, $n, $p)));
27-
result = coloring(A, $problem, $algo);
28-
B = compress(A, result)
29-
)
30+
SUITE[:coloring][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable begin
31+
for A in $As
32+
coloring(A, $problem, $algo)
33+
end
34+
end
35+
36+
SUITE[:decompress][structure][partition][decompression]["n=$n"]["p=$p"] = @benchmarkable begin
37+
for (B, result) in zip($Bs, $results)
38+
if B isa AbstractMatrix
39+
decompress(B, result)
40+
elseif B isa Tuple
41+
decompress(B[1], B[2], result)
42+
end
43+
end
44+
end
3045
end

0 commit comments

Comments
 (0)