Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Daymet single pixel server tests
# load required libraries
if(!require(devtools)){install.package("devtools")}
if(!require(daymetr)){devtools::install_github("khufkens/daymetr")}
library("daymetr")
# no delay calls
no_delay = unlist(lapply(1:100, function(...){
# download data
error = try(download_daymet(silent = TRUE))
# check error
if(inherits(error,"try-error")){
return("error")
} else {
return("pass")
}
}))
# one second delay
delay = unlist(lapply(1:100,function(...){
# sleep
Sys.sleep(1)
# download data
error = try(download_daymet(silent = TRUE))
# check error
if(inherits(error,"try-error")){
return("error")
} else {
return("pass")
}
}))
# plot the tests
pdf("~/server_test.pdf", 4, 7)
par(mfrow = c(2,1))
barplot(table(no_delay),
main = "no delay",
ylab = "percentage (%)")
barplot(table(delay),
main = "1s delay",
ylab = "percentage (%)")
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.