diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml new file mode 100644 index 000000000..098af0cf3 --- /dev/null +++ b/.github/workflows/benchmark.yaml @@ -0,0 +1,36 @@ +name: Run benchmarks + +on: + pull_request: + paths: + - 'EpiAware/**' + merge_group: + paths: + - 'EpiAware/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + Benchmark: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v1 + - uses: julia-actions/cache@v1 + - name: Install dependencies + run: | + julia --project=benchmark -e 'using Pkg; + Pkg.rm("EpiAware"); + Pkg.rm("EpiAwarePipeline"); + Pkg.resolve(); + Pkg.instantiate(); + Pkg.develop(path = "./EpiAware"); + Pkg.develop(path = "./pipeline")' + - name: Run benchmarks + run: julia --project=benchmark -e 'using BenchmarkCI; BenchmarkCI.judge(; baseline = "origin/main")' + - name: Post results + run: julia --project=benchmark -e 'using BenchmarkCI; BenchmarkCI.postjudge()' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 759bf3179..34c9b96bc 100644 --- a/.gitignore +++ b/.gitignore @@ -385,3 +385,7 @@ docs/site/ #Ignore generated Pluto notebooks EpiAware/docs/src/examples/*.md + +# benchmark ignore +/.benchmarkci +/benchmark/*.json diff --git a/EpiAware/.gitignore b/EpiAware/.gitignore index 352da8fa0..bc49b4cee 100644 --- a/EpiAware/.gitignore +++ b/EpiAware/.gitignore @@ -42,3 +42,7 @@ docs/build *.zip .DS_Store + +# benchmark ignore +/.benchmarkci +/benchmark/*.json diff --git a/Project.toml b/Project.toml new file mode 100644 index 000000000..cad82ab95 --- /dev/null +++ b/Project.toml @@ -0,0 +1,8 @@ +name = "Rtwithoutrenewal" +uuid = "5f18122a-2e46-11ef-2c26-2d57cbc8fe48" +authors = ["Samuel Abbott ", "Samuel Brand ", "Zachary Susswein "] +version = "0.1.0-DEV" + +[deps] +EpiAware = "b2eeebe4-5992-4301-9193-7ebc9f62c855" +EpiAwarePipeline = "66314692-3678-4cbb-b3ac-6fcb54505317" diff --git a/benchmark/Project.toml b/benchmark/Project.toml new file mode 100644 index 000000000..c8b3a4241 --- /dev/null +++ b/benchmark/Project.toml @@ -0,0 +1,7 @@ +[deps] +BenchmarkCI = "20533458-34a3-403d-a444-e18f38190b5b" +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" +EpiAware = "b2eeebe4-5992-4301-9193-7ebc9f62c855" +EpiAwarePipeline = "66314692-3678-4cbb-b3ac-6fcb54505317" +PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" diff --git a/benchmark/bench/EpiAwareUtils/EpiAwareUtils.jl b/benchmark/bench/EpiAwareUtils/EpiAwareUtils.jl new file mode 100644 index 000000000..c0a80834b --- /dev/null +++ b/benchmark/bench/EpiAwareUtils/EpiAwareUtils.jl @@ -0,0 +1,10 @@ +module BenchEpiAwareUtils + +using BenchmarkTools, EpiAware + +suite = BenchmarkGroup() + +include("censored_pmf.jl") + +end +BenchEpiAwareUtils.suite diff --git a/benchmark/bench/EpiAwareUtils/censored_pmf.jl b/benchmark/bench/EpiAwareUtils/censored_pmf.jl new file mode 100644 index 000000000..15c3d7db7 --- /dev/null +++ b/benchmark/bench/EpiAwareUtils/censored_pmf.jl @@ -0,0 +1,5 @@ +let + using Distributions + dist = Exponential(1.0) + suite["censored_pmf"] = @benchmarkable(censored_pmf($dist, Δd = 1.0, D = 3.0)) +end diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl new file mode 100644 index 000000000..d87c1a7fa --- /dev/null +++ b/benchmark/benchmarks.jl @@ -0,0 +1,11 @@ +using BenchmarkTools +SUITE = BenchmarkGroup() +for folder in readdir(joinpath(@__DIR__, "bench")) + if isdir(joinpath(@__DIR__, "bench", folder)) + suite_name = basename(folder) + suite_file = joinpath(@__DIR__, "bench", folder, "$suite_name.jl") + if isfile(suite_file) + SUITE[suite_name] = include(suite_file) + end + end +end diff --git a/benchmark/runbenchmarks.jl b/benchmark/runbenchmarks.jl new file mode 100644 index 000000000..3041bdb2d --- /dev/null +++ b/benchmark/runbenchmarks.jl @@ -0,0 +1,11 @@ +using PkgBenchmark +benchmarkpkg( + dirname(@__DIR__), + BenchmarkConfig( + env = Dict( + "JULIA_NUM_THREADS" => "1", + "OMP_NUM_THREADS" => "1" + ), + ), + resultfile = joinpath(@__DIR__, "result.json") +) diff --git a/src/Rtwithoutrenewal.jl b/src/Rtwithoutrenewal.jl new file mode 100644 index 000000000..225d6b2ca --- /dev/null +++ b/src/Rtwithoutrenewal.jl @@ -0,0 +1,6 @@ +module Rtwithoutrenewal + +using EpiAware +using EpiAwarePipeline + +end