mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-11-08 22:21:08 +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
|
mutable struct Particle
|
||||||
id::Int64
|
id::Int64
|
||||||
|
|
||||||
c::Vector{Float64} # Center
|
c::Vector{Float64} # Center
|
||||||
tmp_c::Vector{Float64} # Temporary center
|
tmp_c::Vector{Float64} # Temporary center
|
||||||
|
|
||||||
φ::Float64 # Angle
|
φ::Float64 # Angle
|
||||||
|
|
||||||
function Particle(; id::Int64, c::SVector{2,Float64}, φ::Float64)
|
function Particle(; id::Int64, c::Vector{Float64}, φ::Float64)
|
||||||
return new(id, c, c, φ)
|
return new(id, c, copy(c), φ)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ mutable struct PreVector{T}
|
||||||
last_ind::UInt64
|
last_ind::UInt64
|
||||||
v::Vector{T}
|
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
|
end
|
||||||
|
|
||||||
function push!(pv::PreVector{T}, x::T) where {T}
|
function push!(pv::PreVector{T}, x::T) where {T}
|
||||||
|
|
|
@ -10,11 +10,12 @@ using JLD2: JLD2
|
||||||
using JSON3: JSON3
|
using JSON3: JSON3
|
||||||
|
|
||||||
import Dates: now, CompoundPeriod, canonicalize
|
import Dates: now, CompoundPeriod, canonicalize
|
||||||
import Base: push!, run, iterate
|
import Base: push!, iterate
|
||||||
|
|
||||||
# Development deps
|
# BEGIN dev deps
|
||||||
using Revise
|
using Revise
|
||||||
using BenchmarkTools
|
using BenchmarkTools
|
||||||
|
# END
|
||||||
|
|
||||||
set_theme!(theme_black())
|
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)
|
c = args.c₁ / (distance²^4) * (args.c₂ / (distance²^3) - 1)
|
||||||
|
|
||||||
@turbo for k in 1:2
|
@turbo for k in 1:2
|
||||||
dck = c * r⃗₁₂[k]
|
dc = c * r⃗₁₂[k]
|
||||||
|
|
||||||
p.tmp_c[k] -= dck
|
p.tmp_c[k] -= dc
|
||||||
p2.tmp_c[k] += dck
|
p2.tmp_c[k] += dc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue