-
Notifications
You must be signed in to change notification settings - Fork 53
/
update_perf.jl
36 lines (29 loc) · 1.08 KB
/
update_perf.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using GaussianProcesses
using BenchmarkLite
# Define Benchmark test
type GP_UpdateBenchmark <: Proc
d::Int
op::Function
GP_UpdateBenchmark(d::Int, op::Function) = new(d, op)
end
AbstractString(proc::GP_UpdateBenchmark) = "Dim: $(proc.d)"
Base.length(proc::GP_UpdateBenchmark, cfg) = cfg
Base.isvalid(proc::GP_UpdateBenchmark, cfg) = (isa(cfg, Int) && cfg > 0)
function Base.start(proc::GP_UpdateBenchmark, cfg)
n = cfg
x = 2π * rand(proc.d,n) # Training set
y = Float64[sum(sin(x[:,i])) for i in 1:n]/proc.d # y = 1/d Σᵢ sin(xᵢ)
GP(x, y, MeanZero(), SEIso(0.0,0.0))
end
function Base.run(proc::GP_UpdateBenchmark, cfg, s)
proc.op(s)
end
Base.done(proc::GP_UpdateBenchmark, cfg, s) = nothing
######################
# Inputs parameters
dims = [10, 30, 50, 100] # Dimensions
num_train = [20, 50, 100, 1000] # Num training points
println("Benchmarking update_mll! function....")
mll_procs = vec(Proc[ GP_UpdateBenchmark(d, GaussianProcesses.update_mll_and_dmll!) for d in dims ])
mll_table = run(mll_procs, num_train)
show(mll_table)