mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-12-21 00:51:21 +00:00
Seperate profiling and benchmarking
This commit is contained in:
parent
6fda866f94
commit
ac1826cc3a
2 changed files with 55 additions and 0 deletions
50
performance/Benchmark.jl
Normal file
50
performance/Benchmark.jl
Normal file
|
@ -0,0 +1,50 @@
|
|||
module Benchmark
|
||||
|
||||
using Dates: Dates
|
||||
using BenchmarkTools: @benchmark
|
||||
|
||||
# TODO: Replace JSON3
|
||||
# FIX: Benchmarking
|
||||
|
||||
using ReCo
|
||||
|
||||
function run_benchmarks(
|
||||
dir::String = "";
|
||||
n_particles::Int64 = 1000,
|
||||
v₀::Float64 = 20.0,
|
||||
duration::Float64 = 2.0,
|
||||
n_bundle_snapshots::Int64 = 0,
|
||||
comment = ""
|
||||
)
|
||||
if length(dir) == 0
|
||||
dir = init_sim(; n_particles = n_particles, v₀ = v₀, parent_dir = "benchmark")
|
||||
end
|
||||
|
||||
benchmark = @benchmark run_sim(
|
||||
$dir; duration = $duration, n_bundle_snapshots = $n_bundle_snapshots
|
||||
)
|
||||
|
||||
display(benchmark)
|
||||
|
||||
open("exports/benchmark.txt", "a+") do f
|
||||
JSON3.pretty(
|
||||
f,
|
||||
Dict(
|
||||
"n_particles" => n_particles,
|
||||
"v₀" => v₀,
|
||||
"duration" => duration,
|
||||
"n_bundle_snapshots" => n_bundle_snapshots,
|
||||
"comment" => comment,
|
||||
"datetime" => Dates.now(),
|
||||
"mean_time/ns" => mean(benchmark.times),
|
||||
"allocs" => benchmark.allocs,
|
||||
"memory" => benchmark.memory,
|
||||
),
|
||||
)
|
||||
write(f, "\n")
|
||||
end
|
||||
|
||||
return dir
|
||||
end
|
||||
|
||||
end # module
|
5
performance/Project.toml
Normal file
5
performance/Project.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
[deps]
|
||||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
|
||||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
|
||||
ProfileView = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
|
||||
ReCo = "b25f7548-fcc9-4c91-bc24-841b54f4dd54"
|
Loading…
Reference in a new issue