Skip to content

Commit 929b8a1

Browse files
committed
Set up benchmark CI
This prepares the benchmark for the arithmetic implementation in CheckedArithmeticCore.
1 parent 5750cdb commit 929b8a1

File tree

5 files changed

+105
-1
lines changed

5 files changed

+105
-1
lines changed

.github/workflows/Benchmark.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Run benchmarks
2+
3+
on:
4+
pull_request:
5+
types: [labeled, opened, synchronize, reopened]
6+
workflow_dispatch:
7+
jobs:
8+
Benchmark:
9+
runs-on: ubuntu-latest
10+
if: contains(github.event.pull_request.labels.*.name, 'run benchmark')
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: julia-actions/setup-julia@latest
14+
- name: Cache artifacts
15+
uses: actions/cache@v1
16+
env:
17+
cache-name: cache-artifacts
18+
with:
19+
path: ~/.julia/artifacts
20+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
21+
restore-keys: |
22+
${{ runner.os }}-test-${{ env.cache-name }}-
23+
${{ runner.os }}-test-
24+
${{ runner.os }}-
25+
- name: Install dependencies
26+
run: |
27+
julia --project=./benchmark -e '
28+
using Pkg;
29+
Pkg.develop(PackageSpec(path=pwd()));
30+
Pkg.develop(PackageSpec(path=joinpath(pwd(), "CheckedArithmeticCore")));
31+
Pkg.instantiate();
32+
'
33+
- name: Run benchmarks
34+
run: julia --project=./benchmark -e 'using BenchmarkCI; BenchmarkCI.judge(project="benchmark")'
35+
- name: Post results
36+
run: julia --project=./benchmark -e 'using BenchmarkCI; BenchmarkCI.postjudge()'
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/UnitTest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
with:
2828
version: ${{ matrix.julia-version }}
2929
arch: ${{ matrix.julia-arch }}
30+
show-versioninfo: true
3031
- run: julia --project -e 'using Pkg; Pkg.develop([PackageSpec(path="CheckedArithmeticCore")])'
3132

3233
- name: Cache artifacts

.gitignore

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
# Files generated by invoking Julia with --code-coverage
2+
*.jl.cov
3+
*.jl.*.cov
4+
5+
# Files generated by invoking Julia with --track-allocation
6+
*.jl.mem
7+
8+
# System-specific files and directories generated by the BinaryProvider and BinDeps packages
9+
# They contain absolute paths specific to the host computer, and so should not be committed
10+
deps/deps.jl
11+
deps/build.log
12+
deps/downloads/
13+
deps/usr/
14+
deps/src/
15+
16+
# Build artifacts for creating documentation generated by the Documenter package
17+
docs/build/
18+
docs/site/
19+
20+
# File generated by Pkg, the package manager, based on a corresponding Project.toml
21+
# It records a fixed state of all packages used by the project. As such, it should not be
22+
# committed for packages, but should be committed for applications that require a static
23+
# environment.
24+
Manifest.toml
25+
26+
# Files enerated by BenchmarkCI
27+
/.benchmarkci
28+
/benchmark/*.json
29+
130
.DS_Store
2-
/Manifest.toml
331
/dev/

benchmark/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[deps]
2+
BenchmarkCI = "20533458-34a3-403d-a444-e18f38190b5b"
3+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
4+
CheckedArithmetic = "2c4a1fb8-30c1-4c71-8b84-dff8d59868ee"
5+
CheckedArithmeticCore = "740b204e-26e5-40b1-866a-9c367e60c4b6"
6+
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"

benchmark/benchmarks.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using CheckedArithmeticCore
2+
using BenchmarkTools
3+
using Base.Checked # TODO: re-export
4+
5+
BenchmarkTools.DEFAULT_PARAMETERS.seconds = 1
6+
7+
xs = Dict{Type, Matrix}()
8+
ys = Dict{Type, Matrix}()
9+
zs = Dict{Type, Matrix}()
10+
11+
eltypes = (Int8, UInt8, Int16, UInt16, Int32, UInt32)
12+
for T in eltypes
13+
push!(xs, T => rand(T, 1000, 1000))
14+
push!(ys, T => rand(T, 1000, 1000))
15+
push!(zs, T => zeros(T, 1000, 1000))
16+
end
17+
18+
SUITE = BenchmarkGroup()
19+
SUITE["add"] = BenchmarkGroup([],
20+
"wrapping" => BenchmarkGroup(),
21+
"saturating" => BenchmarkGroup(),
22+
"checked" => BenchmarkGroup(),
23+
)
24+
25+
for T in eltypes
26+
x = xs[T]::Matrix{T}
27+
y = ys[T]::Matrix{T}
28+
z = zs[T]::Matrix{T}
29+
t = string(T)
30+
SUITE["add"]["checked" ][t] = @benchmarkable checked_add.($x, $z)
31+
end

0 commit comments

Comments
 (0)