I am just getting started with using parallel computing in R and I have no idea where I am heading. I am trying to test APIs by passing header names via csv (200+ records) and I am wanting to test it for multiple users (load and performance test).
library(httr)
library(parallel)
library(doParallel)
detectCores()
registerDoParallel(4)
# Headers.csv has names of relevant tables to be tested
headers <- read.csv("Headers.csv")
headers$status <- ""
headers$starttime <- ""
headers$endtime <- ""
# API endpoint
endpoint <- "<api-url>"
for (j in c(1:nrow(headers))) {
# code to read tables with list specified in Headers.csv;
headers$starttime[j] <- format(Sys.time(), "%T")
res <- GET(endpoint,
add_headers('name' = headers[j,"HEADERS"]),
authenticate('UserID','Password'))
headers$endtime[j] <- format(Sys.time(), "%T")
headers$status[j] <- res$status_code
}
write.csv(headers,file='APIstatuscode.csv',row.names = F)
However, I am getting an error - GET function not found. But I feel its a bigger issue. The headers passed via csv has a simple format with one column stating all the header values (200 + records). Thank you.