Skip to content

Commit 33d64d1

Browse files
Add benchmarking CI (JuliaGaussianProcesses#399)
* Add benchmark file * delete old benchmarks * Add github action * Add Project * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Missing end of line Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 360ce10 commit 33d64d1

File tree

6 files changed

+67
-77
lines changed

6 files changed

+67
-77
lines changed

.github/workflows/benchmark.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Run benchmarks
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
Benchmark:
8+
runs-on: ubuntu-latest
9+
if: contains(github.event.pull_request.labels.*.name, 'performance critical')
10+
env:
11+
JULIA_DEBUG: BenchmarkCI
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: julia-actions/setup-julia@latest
15+
with:
16+
version: 1.6
17+
- name: Install dependencies
18+
run: julia -e 'using Pkg; pkg"add PkgBenchmark BenchmarkCI"'
19+
- name: Run benchmarks
20+
run: julia -e "using BenchmarkCI; BenchmarkCI.judge()"
21+
- name: Post results
22+
run: julia -e "using BenchmarkCI; BenchmarkCI.postjudge()"
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/test/Manifest.toml
55
coverage/
66
.DS_store
7+
benchmark/Manifest.toml

benchmark/MLKernels.jl

-22
This file was deleted.

benchmark/Project.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3+
KernelFunctions = "ec8451be-7e33-11e9-00cf-bbf324bd1392"

benchmark/benchmarks.jl

+39-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
11
using BenchmarkTools
2-
using Random
3-
using Distances, LinearAlgebra
2+
using KernelFunctions
43

5-
const SUITE = BenchmarkGroup()
4+
N1 = 10
5+
N2 = 20
66

7-
Random.seed!(1234)
7+
X = rand(N1, N2)
8+
Xc = ColVecs(X)
9+
Xr = RowVecs(X)
10+
Xv = collect.(eachcol(X))
11+
Y = rand(N1, N2)
12+
Yc = ColVecs(Y)
13+
Yr = RowVecs(Y)
14+
Yv = collect.(eachcol(Y))
815

9-
dim = 50
10-
N1 = 1000;
11-
N2 = 500;
12-
alpha = 2.0
16+
# Create the general suite of benchmarks
17+
SUITE = BenchmarkGroup()
1318

14-
X = rand(Float64, N1, dim)
15-
Y = rand(Float64, N2, dim)
19+
kernels = Dict(
20+
"SqExponential" => SqExponentialKernel(), "Exponential" => ExponentialKernel()
21+
)
1622

17-
KXY = rand(Float64, N1, N2)
18-
KX = rand(Float64, N1, N1)
19-
sKX = Symmetric(rand(Float64, N1, N1))
20-
kX = rand(Float64, N1)
23+
inputtypes = Dict("ColVecs" => (Xc, Yc), "RowVecs" => (Xr, Yr), "Vecs" => (Xv, Yv))
2124

22-
include("kernelmatrix.jl")
23-
include("MLKernels.jl")
25+
functions = Dict(
26+
"kernelmatrixX" => (kernel, X, Y) -> kernelmatrix(kernel, X),
27+
"kernelmatrixXY" => (kernel, X, Y) -> kernelmatrix(kernel, X, Y),
28+
"kernelmatrix_diagX" => (kernel, X, Y) -> kernelmatrix_diag(kernel, X),
29+
"kernelmatrix_diagXY" => (kernel, X, Y) -> kernelmatrix_diag(kernel, X, Y),
30+
)
31+
32+
for (kname, kernel) in kernels
33+
SUITE[kname] = sk = BenchmarkGroup()
34+
for (inputname, (X, Y)) in inputtypes
35+
sk[inputname] = si = BenchmarkGroup()
36+
for (fname, f) in functions
37+
si[fname] = @benchmarkable $f($kernel, $X, $Y)
38+
end
39+
end
40+
end
41+
42+
# Uncomment the following to run benchmark locally
43+
44+
# tune!(SUITE)
45+
46+
# results = run(SUITE, verbose=true)

benchmark/kernelmatrix.jl

-39
This file was deleted.

0 commit comments

Comments
 (0)