Skip to content

Add benchmark GHA #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: benchmarks
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
pull_request:
branches:
- master
- main
paths-ignore:
- 'LICENSE.md'
- 'README.md'
- 'docs/**'
- 'format/**'
- 'test/**'
jobs:
benchmarks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
with:
version: "1"
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- name: Benchmark
run: |
git fetch origin +:refs/remotes/origin/HEAD
julia --project=benchmark/ -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
# Pkg.update() allows us to benchmark even when dependencies/compat requirements change
julia --project=benchmark/ -e '
using PkgBenchmark, Loess
juliacmd = `$(Base.julia_cmd()) -O3 -e "using Pkg; Pkg.update()"`
config = BenchmarkConfig(; id="origin/HEAD", juliacmd)
export_markdown(stdout, judge(Loess, config; verbose=true))'
10 changes: 10 additions & 0 deletions benchmark/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Loess = "4345ca2d-374a-55d4-8d30-97f9976e7612"
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
BenchmarkTools = "1"
PkgBenchmark = "0.2"
julia = "1"
19 changes: 19 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using BenchmarkTools, Loess, Random

const SUITE = BenchmarkGroup()

SUITE["random"] = BenchmarkGroup()

for i in 2:6
n = 10^i
x = rand(MersenneTwister(42), n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth using StableRNGs here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it and probably not -- we don't care about the precise values and this is always run within the same Julia version for each new PR

y = sqrt.(x)
SUITE["random"][string(n)] = @benchmarkable loess($x, $y)
end

SUITE["ties"] = BenchmarkGroup()
let
x = repeat([π/4*i for i in -20:20], inner=101)
y = sin.(x)
SUITE["ties"]["sine"] = @benchmarkable loess($x, $y; span=0.2)
end