Commit 06699cb1 authored by Forquet Nicolas's avatar Forquet Nicolas
Browse files

fix an issue do to the transition from windows 7 to windows 10. The typeperf...

fix an issue do to the transition from windows 7 to windows 10. The typeperf function used previously is deprecated and has been replaced by wmic. File processor_load.bat is no longer required.
parent 267618a1
No related merge requests found
Showing with 5 additions and 10 deletions
+5 -10
......@@ -83,7 +83,7 @@ for (i in 1:nb.runs){
Finally, we run the simulations using the function *simulation.run*. This function output the computing time:
```{r eval=FALSE, include=FALSE}
output <- simulation.run(nb.runs,paste0(here("hydrus"),"/processor_load.bat"),main_directory,generic.name,hydrus.calc="H1D_Calc.exe")
output <- simulation.run(nb.runs,main_directory,generic.name,hydrus.calc="H1D_Calc.exe")
print(output)
```
typeperf "\processeur(_Total)\%% temps processeur" -sc 5
# This function process the output of the script .bat that estimates processor usage.
output.bat <- function(output){
usage <- rep(0,5)
for (i in 1:5){
usage[i] <- as.numeric(strsplit(output[4+i],split='"',fixed=TRUE)[[1]][4])
}
mean_usage <- mean(usage)
return(mean_usage)
usage <- as.numeric(trimws(strsplit(output[2],"\r")))
return(usage)
}
# This function creates the file tree necessary to run simulation
......@@ -24,13 +20,13 @@ simulation.setup <- function(nb.runs,generic.name,main.directory,hydrus.folder,n
}
}
simulation.run <- function(nb.runs,processor_load_path,main_directory,generic.name,hydrus.calc="H1D_Calc.exe"){
simulation.run <- function(nb.runs,main_directory,generic.name,hydrus.calc="H1D_Calc.exe"){
start.time <- Sys.time()
sim.counter <- 0
while (sim.counter < nb.runs){
# how busy the processor is?
temp <- system(processor_load_path,intern = TRUE)
temp <- system("wmic cpu get loadpercentage",intern = TRUE) # the processor_load_path is a .bat file (i.e. a batch file in windows system)
processor.usage <- output.bat(temp)
if (processor.usage < 75){
# if processor usage is less than 75%, start a new run
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment