mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2025-01-09 16:10:26 +00:00
benchmarks
This commit is contained in:
parent
092b0438d3
commit
10018160e2
5 changed files with 33 additions and 9 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue