-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmark.jl
31 lines (24 loc) · 1.11 KB
/
benchmark.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#]add BenchmarkTools
using BenchmarkTools
using PlantSimEngine, PlantMeteo, DataFrames, CSV, Dates, Statistics
# using PlantSimEngine.Examples
meteo_day = read_weather(joinpath(pkgdir(PlantSimEngine), "examples/meteo_day.csv"), duration=Day)
models = ModelList(
ToyLAIModel(),
status=(TT_cu=cumsum(meteo_day.TT),),
)
# Match the warning on the executor, the default is ThreadedEx() but ToyRUEGrowthModel can't be run in parallel:
time_run = @benchmark run!($models, $meteo_day)
median_time_ns = median(time_run.times) / nrow(meteo_day)
# If we provide a serial executor, it works without a warning:
time_run_seq = @benchmark run!($models, $meteo_day, executor=$(SequentialEx()))
median_time_seq_ns = median(time_run_seq.times) / nrow(meteo_day)
# Coupled model:
models_coupled = ModelList(
ToyLAIModel(),
Beer(0.5),
status=(TT_cu=cumsum(meteo_day.TT),),
)
# Match the warning on the executor, the default is ThreadedEx() but ToyRUEGrowthModel can't be run in parallel:
time_run_coupled = @benchmark run!($models_coupled, $meteo_day)
median_time_coupled_ns = median(time_run_coupled.times) / nrow(meteo_day)