Skip to content

Commit 600cbc2

Browse files
authored
try to add benchmark code for CI (#548)
1 parent b275df1 commit 600cbc2

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

.github/workflows/benchmark_pr.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Run benchmarks
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
Benchmark:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: julia-actions/setup-julia@latest
12+
with:
13+
version: 1
14+
- uses: julia-actions/julia-buildpkg@latest
15+
- name: Install dependencies
16+
run: julia -e 'using Pkg; pkg"add PkgBenchmark [email protected]"'
17+
- name: Run benchmarks
18+
run: julia -e 'using BenchmarkCI; BenchmarkCI.displayjudgement()'
19+
- name: Post results
20+
run: julia -e 'using BenchmarkCI; BenchmarkCI.postjudge()'
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ docs/site/
55
*.jl.mem
66

77
Manifest.toml
8-
archive/
8+
archive/
9+
/.benchmarkci
10+
/benchmark/*.json

src/benchmark/benchmarks.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using BenchmarkTools
2+
using Polynomials
3+
4+
Ps = (P=Polynomial, IP=ImmutablePolynomial, SP=SparsePolynomial,
5+
LP=LaurentPolynomial)
6+
7+
const SUITE = BenchmarkGroup()
8+
9+
for P Ps
10+
P′ = string(P)
11+
SUITE[P′] = BenchmarkGroup(["Polynomials", P′])
12+
SUITE[P′]["evaluation"] =
13+
(@benchmarkable p(c) setup=(p=$P(rand(20)); c=rand()))
14+
SUITE[P′]["scalar addition"] =
15+
(@benchmarkable p + c setup=(p=$P(rand(20)); c=rand()))
16+
SUITE[P′]["scalar multiplication"] =
17+
(@benchmarkable p * c setup=(p=$P(rand(20)); c=rand()))
18+
SUITE[P′]["scalar divistion"] =
19+
(@benchmarkable p / c setup=(p=$P(rand(20)); c=rand()))
20+
SUITE[P′]["poly addition"] =
21+
(@benchmarkable p + q setup=(p=$P(rand(20)); q = $P(rand(25))))
22+
SUITE[P′]["poly multiplication"] =
23+
(@benchmarkable p * q setup=(p=$P(rand(20)); q = $P(rand(25))))
24+
SUITE[P′]["mixed var add"] =
25+
(@benchmarkable p + q setup=(p=$P(rand(20)); q=$P(rand(1),:y)))
26+
SUITE[P′]["mixed var mul"] =
27+
(@benchmarkable p * q setup=(p=$P(rand(20)); q=$P(rand(1),:y)))
28+
SUITE[P′]["differentiation"] =
29+
(@benchmarkable derivative(p) setup=(p=$P(rand(20))))
30+
SUITE[P′]["integration"] =
31+
(@benchmarkable integrate(p) setup=(p=$P(rand(20))))
32+
end

0 commit comments

Comments
 (0)