2021-12-07 00:36:47 +00:00
|
|
|
using Statistics: mean
|
|
|
|
using Dates: now
|
|
|
|
using BenchmarkTools: @benchmark
|
|
|
|
using JSON3: JSON3
|
2021-11-26 02:35:39 +00:00
|
|
|
|
2021-12-07 00:36:47 +00:00
|
|
|
using ReCo
|
2021-11-26 02:35:39 +00:00
|
|
|
|
2021-12-07 00:36:47 +00:00
|
|
|
function run_benchmarks(
|
|
|
|
dir::String="";
|
|
|
|
N::Int64=1000,
|
|
|
|
v::Float64=20.0,
|
|
|
|
duration::Float64=2.0,
|
|
|
|
n_bundle_snapshots::Int64=0,
|
|
|
|
comment="",
|
|
|
|
)
|
|
|
|
if length(dir) == 0
|
|
|
|
dir = init_sim(; N=N, v=v, parent_dir="benchmark")
|
|
|
|
end
|
|
|
|
|
|
|
|
benchmark = @benchmark run_sim(
|
|
|
|
$dir; duration=$duration, n_bundle_snapshots=$n_bundle_snapshots
|
|
|
|
)
|
2021-11-26 02:35:39 +00:00
|
|
|
|
2021-12-07 00:36:47 +00:00
|
|
|
display(benchmark)
|
2021-11-26 02:35:39 +00:00
|
|
|
|
2021-12-07 00:36:47 +00:00
|
|
|
open("exports/benchmark.txt", "a+") do f
|
|
|
|
JSON3.pretty(
|
|
|
|
f,
|
|
|
|
Dict(
|
|
|
|
"N" => N,
|
|
|
|
"v" => v,
|
|
|
|
"duration" => duration,
|
|
|
|
"n_bundle_snapshots" => n_bundle_snapshots,
|
|
|
|
"comment" => comment,
|
|
|
|
"datetime" => now(),
|
|
|
|
"mean_time/ns" => mean(benchmark.times),
|
|
|
|
"allocs" => benchmark.allocs,
|
|
|
|
"memory" => benchmark.memory,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
write(f, "\n")
|
2021-11-26 02:35:39 +00:00
|
|
|
end
|
2021-12-07 00:36:47 +00:00
|
|
|
|
|
|
|
return dir
|
2021-11-26 02:35:39 +00:00
|
|
|
end
|