diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index 159c40c..9bf2d1b 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -1,16 +1,18 @@ using BenchmarkTools -BenchmarkTools.DEFAULT_PARAMETERS.seconds = 1 +# Default benchmark parameters +BenchmarkTools.DEFAULT_PARAMETERS.seconds = 1.0 -const SUITE = BenchmarkGroup() - -module BenchmarkGCP - include("gcp.jl") -end +# Benchmark suite modules +const SUITE_MODULES = Dict("gcp" => :BenchmarkGCP, "mttkrp" => :BenchmarkMTTKRP) +const DEFAULT_SUITES = join(keys(SUITE_MODULES), ' ') -module BenchmarkMTTKRP - include("mttkrp.jl") +# Create top-level suite including only sub-suites +# specified by ENV variable "GCP_BENCHMARK_SUITES" +const SUITE = BenchmarkGroup() +SELECTED_SUITES = split(get(ENV, "GCP_BENCHMARK_SUITES", DEFAULT_SUITES)) +for suite_name in SELECTED_SUITES + module_name = SUITE_MODULES[suite_name] + include(joinpath(@__DIR__, "$(suite_name).jl")) + SUITE[suite_name] = eval(module_name).SUITE end - -SUITE["gcp"] = BenchmarkGCP.SUITE -SUITE["mttkrp"] = BenchmarkMTTKRP.SUITE \ No newline at end of file diff --git a/benchmark/gcp.jl b/benchmark/gcp.jl index af361c1..77309c4 100644 --- a/benchmark/gcp.jl +++ b/benchmark/gcp.jl @@ -1,3 +1,5 @@ +module BenchmarkGCP + using BenchmarkTools using Random @@ -40,3 +42,5 @@ for sz in [(15, 20, 25), (30, 40, 50)], r in 1:2 X = [rand(Bernoulli(M[I]/(M[I] + 1))) for I in CartesianIndices(size(M))] bench_gcp["bernoulliOdds-size(X)=$sz, rank(X)=$r"] = @benchmarkable gcp($X, $r, BernoulliOddsLoss()) end + +end \ No newline at end of file diff --git a/benchmark/mttkrp.jl b/benchmark/mttkrp.jl index 453e968..ab3c78a 100644 --- a/benchmark/mttkrp.jl +++ b/benchmark/mttkrp.jl @@ -1,3 +1,5 @@ +module BenchmarkMTTKRP + using BenchmarkTools using Random @@ -17,4 +19,6 @@ for sz in shapes, r in rs X = randn(sz) U = [randn(Ik,r) for Ik in sz] bench_mttkrp["mttkrp-size(X)=$sz, rank(X)=$r"] = @benchmarkable GCPDecompositions.mttkrp($X, $U, $n) +end + end \ No newline at end of file