Skip to content

Commit

Permalink
Merge pull request #108 from ErikQQY/qqy/better_bench
Browse files Browse the repository at this point in the history
Add better benchmarks
  • Loading branch information
ErikQQY authored Apr 5, 2024
2 parents 1af9086 + 8cbe7f9 commit 48be112
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 7 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/Benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Benchmarks
on:
push:
branches:
- master
pull_request:
branches:
- master

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: '1'
arch: x64
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Run benchmark
run: |
cd bench
julia --project --color=yes -e '
using Pkg;
Pkg.develop(PackageSpec(path=joinpath(pwd(), "..")));
Pkg.instantiate();
include("runbenchmarks.jl")'
- name: Parse & Upload Benchmark Results
uses: benchmark-action/github-action-benchmark@v1
with:
name: Benchmark Results
tool: 'julia'
output-file-path: bench/benchmark_results.json
summary-always: true
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true
alert-threshold: "200%"
fail-on-alert: true
benchmark-data-dir-path: benchmarks
auto-push: ${{ github.event_name != 'pull_request' }}
9 changes: 9 additions & 0 deletions bench/.JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
style = "sciml"
whitespace_in_kwargs = false
always_use_return = true
margin = 92
indent = 4
format_docstrings = true
separate_kwargs_with_semicolon = true
always_for_in = true
annotate_untyped_fields_with_any = false
5 changes: 5 additions & 0 deletions bench/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
FractionalDiffEq = "c7492dd8-6170-483b-af64-cefb6c377d9a"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
10 changes: 10 additions & 0 deletions bench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# FractionalDiffEq.jl Continuous Benchmarking

Currently we use the BenchmarkTools.jl package to benchmark the performance of FractionalDiffEq.jl over time.

This is built using https://github.com/benchmark-action/github-action-benchmark/ so it
allows for nice visualizations of the benchmark results in github pages and produces warnings on PRs if the benchmarks regress.

## Current Benchmarks

1. Small VGG Net for CIFAR-10
25 changes: 25 additions & 0 deletions bench/runbenchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using BenchmarkTools: BenchmarkTools, BenchmarkGroup, @btime, @benchmarkable
using FractionalDiffEq
using Statistics: median

const SUITE = BenchmarkGroup()

α = [0.8, 0.8]
u0 = [0.2, 0.03]

function Brusselator!(du, u, p, t)
a, μ = 1, 4
du[1] = a-+1)*u[1]+(u[1])^2*u[2]
du[2] = μ*u[1]-(u[1])^2*u[1]
end

prob = FODEProblem(Brusselator!, α, u0, (0, 20))

SUITE["FLMM"]["BDF"] = @benchmarkable solve(prob, BDF(), dt=0.01)
SUITE["FLMM"]["Trapezoid"] = @benchmarkable solve(prob, Trapezoid(), dt=0.01)
SUITE["FLMM"]["NewtonGregory"] = @benchmarkable solve(prob, NewtonGregory(), dt=0.01)

BenchmarkTools.tune!(SUITE)
results = BenchmarkTools.run(SUITE; verbose=true)

BenchmarkTools.save(joinpath(@__DIR__, "benchmark_results.json"), median(results))
8 changes: 4 additions & 4 deletions docs/src/get_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

We would use a simple example -- [Relaxation Oscillation Process](https://encyclopediaofmath.org/wiki/Relaxation_oscillation) to show you how to use FractionalDiffEq.jl to solve fractional differential equations.🙂

The mathematical model of the fractional order Relaxation Oscillation can be abstracted as an IVP:
The mathematical model of the fractional order relaxation oscillation can be abstracted as an IVP:

```math
D^{1.8}y(t)+y(t)=1,\ (t>0)
Expand Down Expand Up @@ -39,7 +39,7 @@ To provide users with a simple way to solve fractional differential equations, w

## Step 1: Defining a Problem

First, we need to specify the problem we want to solve. Just by passing the parameters —— describing function, orders, initial condition and time span:
First, we need to specify the problem we want to solve. Just by passing the parameters —— describing function, orders, initial condition and time span to construct a fractional ordinary differential equation problem:

```julia
using FractionalDiffEq
Expand All @@ -52,13 +52,13 @@ The ```FODEProblem``` is a class of fractional differential equations, describin

## Step 2: Solving a Problem

After defining a problem, we can solve it by calling the ```solve``` function:
After defining a problem, we can solve it by choosing a numerical algorithm and calling the ```solve``` function:

```julia
sol = solve(prob, Alg(), dt=0.01)
```

Note that there are different algorithms for differential fractional differential equations, such as FODE, FDDE and DODE, we need to choose a suitable algorithm for a specific problem. For all the algorithms, please refer to [the algorithms documentation](@ref algorithms).
Note that there are different algorithms for different fractional differential equations, such as FODE, FDDE and DODE, we need to choose a suitable algorithm for a specific problem. For all the algorithms, please refer to [the algorithms documentation](@ref algorithms).

## Step 3: Analyzing the Solution

Expand Down
6 changes: 3 additions & 3 deletions src/FractionalDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ include("fode/explicit_pi.jl")
include("fode/implicit_pi_rectangle.jl")
include("fode/implicit_pi_trapzoid.jl")
include("fode/grunwald_letnikov.jl")
include("fode/NonLinear.jl")
include("fode/nonlinearalg.jl")
include("fode/newton_polynomials.jl")
include("fode/atangana_seda.jl")

# System of fractal-fractional ordinary differential equations
include("ffode/atangana_seda.jl")

# Fractional delay differential equations
include("delay/DelayPECE.jl")
include("delay/pece.jl")
include("delay/product_integral.jl")
include("delay/matrix_form.jl")
include("delay/DelayABM.jl")
include("delay/abm.jl")

# Distributed order differential equations
include("dode/utils.jl")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 48be112

Please sign in to comment.