diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..fcb99013 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,29 @@ +name: Benchmark this PR + +on: + pull_request: + branches: [main] + paths-ignore: ['docs/**'] + +permissions: + pull-requests: write + contents: read + +jobs: + benchmark: + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + version: ["1", "lts"] + env: + # Force consistent Julia depot path for self-hosted runners + JULIA_DEPOT_PATH: ~/.julia + steps: + - uses: MilesCranmer/AirspeedVelocity.jl@action-v1 + with: + julia-version: ${{ matrix.version }} + script: "benchmark/benchmarks.jl" + extra-pkgs: "ModelingToolkit" + job-summary: true diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl new file mode 100644 index 00000000..5863a8e1 --- /dev/null +++ b/benchmark/benchmarks.jl @@ -0,0 +1,32 @@ +using ModelOrderReduction, BenchmarkTools +using ModelingToolkit + +const SUITE = BenchmarkGroup() + +@independent_variables t +@variables u(t)[1:4] +D = Differential(t) +snapshot = [ + sin(0.3 * i * j) + cos(0.2 * i * (j + 1)) for i in 1:4, j in 1:8 +] + +@mtkcompile sys = System([D(u) ~ -u - u .^ 3], t) +csys = complete(sys) + +# ============================================================================= +# DEIM reduction (symbolic system + snapshot matrix) +# ============================================================================= + +SUITE["deim"] = BenchmarkGroup() + +SUITE["deim"]["deim_2"] = @benchmarkable deim($csys, $snapshot, 2) +SUITE["deim"]["deim_3"] = @benchmarkable deim($csys, $snapshot, 3) + +# ============================================================================= +# POD-Galerkin reduction +# ============================================================================= + +SUITE["pod"] = BenchmarkGroup() + +SUITE["pod"]["pod_2"] = @benchmarkable pod($csys, $snapshot, 2) +SUITE["pod"]["pod_3"] = @benchmarkable pod($csys, $snapshot, 3)