Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
HYCAR-Hydro
airGR
Commits
3398e7d4
Commit
3398e7d4
authored
Nov 03, 2021
by
Delaigue Olivier
Browse files
test(benchmark): remove useless variable and format style
Refs #136
parent
c639cd6d
Pipeline
#28792
passed with stages
in 38 minutes and 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/scheduled_tests/benchmarkRunModel.R
View file @
3398e7d4
library
(
airGR
)
source
(
"tests/testthat/helper_scheduled_Calibration.R"
)
BenchmarkRunModel
<-
function
(
model
)
{
e
<-
PrepareCalibration
(
model
)
for
(
n
in
ls
(
e
,
all.names
=
TRUE
))
assign
(
n
,
get
(
n
,
e
))
for
(
n
in
ls
(
e
,
all.names
=
TRUE
))
{
assign
(
n
,
value
=
get
(
n
,
e
))
}
# RunOptions calibration configuration
RunOptions
$
Outputs_Sim
<-
RunOptions
$
Outputs_Cal
mbm
<-
microbenchmark
::
microbenchmark
(
RunModel
=
RunModel
(
InputsModel
=
InputsModel
,
RunOptions
=
RunOptions
,
Param
=
as.numeric
(
strsplit
(
model
$
ParamFinalR
,
";"
)[[
1
]]),
FUN_MOD
=
sModel
)
mbm
<-
microbenchmark
::
microbenchmark
(
RunModel
=
RunModel
(
InputsModel
=
InputsModel
,
RunOptions
=
RunOptions
,
Param
=
as.numeric
(
strsplit
(
model
$
ParamFinalR
,
";"
)[[
1
]]),
FUN_MOD
=
sModel
)
)
mbm
$
time
return
(
mbm
$
time
)
}
Args
<-
commandArgs
(
trailingOnly
=
TRUE
)
sModelNames
<-
paste0
(
dfModels
$
name
,
ifelse
(
as.logical
(
dfModels
$
IsHyst
),
"_Hyst"
,
""
))
ifelse
(
as.logical
(
dfModels
$
IsHyst
),
"_Hyst"
,
""
))
dfBM
<-
as.data.frame
(
apply
(
dfModels
,
1
,
BenchmarkRunModel
))
dfBM
<-
as.data.frame
(
apply
(
dfModels
,
MARGIN
=
1
,
FUN
=
BenchmarkRunModel
))
colnames
(
dfBM
)
<-
sModelNames
dfBM
<-
cbind
(
version
=
as.character
(
packageVersion
(
'airGR'
)),
dfBM
)
...
...
@@ -31,15 +35,15 @@ write.table(dfBM, file = file,
sep
=
"\t"
,
append
=
file.exists
(
file
))
df
<-
read.table
(
file
=
file
,
sep
=
"\t"
,
header
=
TRUE
)
if
(
length
(
unique
(
df
$
version
))
>
1
)
{
if
(
length
(
unique
(
df
$
version
))
>
1
)
{
lV
<-
lapply
(
unique
(
df
$
version
),
function
(
version
)
{
apply
(
df
[
df
$
version
==
version
,
-1
]
/
1
E
6
,
2
,
mean
)
apply
(
df
[
df
$
version
==
version
,
-1
]
/
1
e
6
,
MARGIN
=
2
,
FUN
=
mean
)
})
names
(
lV
)
<-
unique
(
df
$
version
)
dfMean
<-
cbind
(
model
=
sModelNames
,
as.data.frame
(
t
(
do.call
(
rbind
,
lV
))))
dfMean
$
evolution
<-
(
dfMean
[,
3
]
-
dfMean
[,
2
])
/
dfMean
[,
2
]
write.table
(
dfMean
,
"tests/tmp/mean_execution_time.tsv"
,
row.names
=
FALSE
,
quote
=
F
,
sep
=
"\t"
)
dfMean
$
evolution
<-
(
dfMean
[,
3
]
-
dfMean
[,
2
])
/
dfMean
[,
2
]
write.table
(
dfMean
,
"tests/tmp/mean_execution_time.tsv"
,
row.names
=
FALSE
,
quote
=
F
ALSE
,
sep
=
"\t"
)
res
<-
testthat
::
test_file
(
"tests/testthat/benchmarkRunModel.R"
)
dRes
<-
as.data.frame
(
res
)
if
(
any
(
dRes
[,
"failed"
]
>
0
)
|
any
(
dRes
[,
"error"
]))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment