Skip to content

Commit

Permalink
Remove randomness from benchmarks (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill authored Aug 12, 2024
1 parent f1ec8b1 commit c816441
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions benchmark/hessian.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using BenchmarkTools

using ADTypes: hessian_sparsity
using SparseConnectivityTracer

using SparseArrays: sprand
using Random: MersenneTwister

#=
Test cases taken from the article:
Expand Down Expand Up @@ -62,7 +60,7 @@ struct RandomSparsity
end

function RandomSparsity(N::Integer, K::Integer)
rand_sets = [rand(1:N, K) for i in 1:N]
rand_sets = [rand(MersenneTwister(123 + i), 1:N, K) for i in 1:N]
return RandomSparsity(rand_sets)
end

Expand Down
5 changes: 2 additions & 3 deletions benchmark/jacobian.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using BenchmarkTools

using ADTypes: AbstractSparsityDetector, jacobian_sparsity
using SparseConnectivityTracer
using SparseConnectivityTracerBenchmarks.ODE: Brusselator!, brusselator_2d_loop!

using Random: MersenneTwister
using SparseArrays: sprand
using SimpleDiffEq: ODEProblem, solve, SimpleEuler
using Flux: Conv
Expand All @@ -23,7 +22,7 @@ struct IteratedSparseMul{M<:AbstractMatrix}
end

function IteratedSparseMul(; n::Integer, p::Real=0.1, depth::Integer=5)
As = [sprand(n, n, p) for _ in 1:depth]
As = [sprand(MersenneTwister(123 + i), n, n, p) for i in 1:depth]
return IteratedSparseMul(As)
end

Expand Down

0 comments on commit c816441

Please sign in to comment.