1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-09-19 19:01:17 +00:00

benchmarks

This commit is contained in:
MoBit 2021-11-26 03:35:39 +01:00
parent 092b0438d3
commit 10018160e2
5 changed files with 33 additions and 9 deletions

View file

@ -1,12 +1,13 @@
mutable struct Particle
id::Int64
c::Vector{Float64} # Center
tmp_c::Vector{Float64} # Temporary center
φ::Float64 # Angle
function Particle(; id::Int64, c::SVector{2,Float64}, φ::Float64)
return new(id, c, c, φ)
function Particle(; id::Int64, c::Vector{Float64}, φ::Float64)
return new(id, c, copy(c), φ)
end
end

View file

@ -2,7 +2,7 @@ mutable struct PreVector{T}
last_ind::UInt64
v::Vector{T}
PreVector(T, N) = new{T}(UInt64(0), Vector{T}(undef, N))
PreVector{T}(N) where {T} = new{T}(UInt64(0), Vector{T}(undef, N))
end
function push!(pv::PreVector{T}, x::T) where {T}

View file

@ -10,11 +10,12 @@ using JLD2: JLD2
using JSON3: JSON3
import Dates: now, CompoundPeriod, canonicalize
import Base: push!, run, iterate
import Base: push!, iterate
# Development deps
# BEGIN dev deps
using Revise
using BenchmarkTools
# END
set_theme!(theme_black())

View file

@ -1 +1,23 @@
using BenchmarkTools
function run_benchmarks()
benchmark_exprs = [:(run_sim(; N=1000, T=5, v=20.0, snapshot_at=0.1, save_data=false))]
for expr in benchmark_exprs
benchmark = @benchmark eval(expr)
display(benchmark)
open("benchmark.txt", "a+") do f
json = JSON3.pretty(
Dict(
"benchmark" => repr(expr),
"datetime" => now(),
"mean_time/ns" => mean(benchmark.times),
"allocs" => benchmark.allocs,
"memory" => benchmark.memory,
),
)
write(f, json)
end
end
end

View file

@ -37,10 +37,10 @@ function euler!(args)
c = args.c₁ / (distance²^4) * (args.c₂ / (distance²^3) - 1)
@turbo for k in 1:2
dck = c * r⃗₁₂[k]
dc = c * r⃗₁₂[k]
p.tmp_c[k] -= dck
p2.tmp_c[k] += dck
p.tmp_c[k] -= dc
p2.tmp_c[k] += dc
end
end
end