mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2025-09-04 09:12:35 +00:00
Remove kwargs overhead
This commit is contained in:
parent
79a7f84808
commit
ce81dd932b
7 changed files with 61 additions and 38 deletions
|
@ -1,23 +1,45 @@
|
|||
function run_benchmarks()
|
||||
benchmark_exprs = [:(run_sim(; N=1000, T=5, v=20.0, snapshot_at=0.1, save_data=false))]
|
||||
using Statistics: mean
|
||||
using Dates: now
|
||||
using BenchmarkTools: @benchmark
|
||||
using JSON3: JSON3
|
||||
|
||||
for expr in benchmark_exprs
|
||||
benchmark = @benchmark eval(expr)
|
||||
using ReCo
|
||||
|
||||
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
|
||||
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
|
||||
)
|
||||
|
||||
display(benchmark)
|
||||
|
||||
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")
|
||||
end
|
||||
|
||||
return dir
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue