Skip to content

Commit 5f3fc18

Browse files
committed
setup benchmarks
1 parent 2b993cf commit 5f3fc18

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
module MPSKitBenchmarks
2+
3+
using BenchmarkTools
4+
using MPSKit
5+
using TOML
6+
7+
BenchmarkTools.DEFAULT_PARAMETERS.seconds = 20.0
8+
BenchmarkTools.DEFAULT_PARAMETERS.samples = 10000
9+
BenchmarkTools.DEFAULT_PARAMETERS.time_tolerance = 0.15
10+
BenchmarkTools.DEFAULT_PARAMETERS.memory_tolerance = 0.01
11+
12+
const PARAMS_PATH = joinpath(@__DIR__, "etc", "params.json")
13+
const SUITE = BenchmarkGroup()
14+
const MODULES = Dict{String, Symbol}(
15+
"derivatives" => :Derivatives
16+
)
17+
18+
load!(id::AbstractString; kwargs...) = load!(SUITE, id; kwargs...)
19+
20+
function load!(group::BenchmarkGroup, id::AbstractString; tune::Bool = false)
21+
modsym = MODULES[id]
22+
modpath = joinpath(dirname(@__FILE__), id, "$(modsym).jl")
23+
Core.eval(@__MODULE__, :(include($modpath)))
24+
mod = Core.eval(@__MODULE__, modsym)
25+
modsuite = @invokelatest getglobal(mod, :SUITE)
26+
group[id] = modsuite
27+
if tune
28+
results = BenchmarkTools.load(PARAMS_PATH)[1]
29+
haskey(results, id) && loadparams!(modsuite, results[id], :evals)
30+
end
31+
return group
32+
end
33+
34+
loadall!(; kwargs...) = loadall!(SUITE; kwargs...)
35+
36+
function loadall!(group::BenchmarkGroup; verbose::Bool = true, tune::Bool = false)
37+
for id in keys(MODULES)
38+
if verbose
39+
print("loading group $(repr(id))... ")
40+
time = @elapsed load!(group, id, tune = false)
41+
println("done (took $time seconds)")
42+
else
43+
load!(group, id; tune = false)
44+
end
45+
end
46+
if tune
47+
results = BenchmarkTools.load(PARAMS_PATH)[1]
48+
for (id, suite) in group
49+
haskey(results, id) && loadparams!(suite, results[id], :evals)
50+
end
51+
end
52+
return group
53+
end
54+
55+
end

benchmark/Project.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
BlockTensorKit = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd"
4+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
5+
MPSKit = "bb1c41ca-d63c-52ed-829e-0820dda26502"
6+
MPSKitModels = "ca635005-6f8c-4cd1-b51d-8491250ef2ab"
7+
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
8+
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"

0 commit comments

Comments
 (0)