mercredi 28 février 2018

R rough guide



Working directory
getwd()

setwd("D:\\data\\Core kpi\\workspace\\tekpi-service\\src\\test\\resources\\data\\performance")

Loading data from external files

testplan.1_users.20171228 <- data="" ore="" read.csv="" u="">kpi
/workspace/tekpi-service/src/test/resources/data/performance/testplan-per-query-aggregate-1_users-20171228.csv")

Converting from Posix Date

In jmeter, the date are stored in POSIX format (number of millis since 1970), in order to generate propely the date. Use the following commande.

.1_users.20171228$timeStamp/1000,origin ="1970-01-01", tz = "GMT"))

View a table
View(testplan.1_users.20171228)

Install a package
install.packages("ggplot2")

load a library
library("ggplot2")

dataTestFiles<- u="">dir
(pattern = "testplan-per-query-aggregate-.*-20180125.*")

Process a batch of file
testplan<-null span="">
for (filename in dataTestFiles) {
  print(filename);
  nbUserStr<-sub u="">testplan
-per-query-aggregate-","",filename)
  nbUserStr<-sub nbuserstr="" span="" users="">
  nbUserStr<- u="">strsplit
(nbUserStr,"-")[[1]][1]
  nbUser<-as .numeric="" nbuserstr="" span="">
  print(substr(filename,30,30));
  temptestplan <- filename="" read.csv="" span="">
  temptestplan$nbuser=nbUser;
  splittedData <- data.frame="" do.call="" u="">rbind
', strsplit(as.character(temptestplan$label),'-',fixed=TRUE)))
  temptestplan<- u="">cbind
(temptestplan,splittedData)
  temptestplan$session=filename;
  testplan<- u="">rbind
(testplan,temptestplan)
}

Agregate on function
aggregate(x=testplanclean$elapsed,by=list(testplanclean$session),FUN='mean')
aggregate(x=testplanclean$elapsed,by=list(testplanclean$session),FUN='var')
aggregate(x=testplanclean$elapsed,by=list(testplanclean$session),FUN='max')
nbReqSession<-aggregate x="<u">testplanclean
$elapsed,by=list(testplanclean$session),FUN='length')
startSession<-aggregate x="<u">testplanclean
$timeStamp,by=list(testplanclean$session),FUN='min')
endSession<-aggregate x="<u">testplanclean
$timeStamp,by=list(testplanclean$session),FUN='max')
intensite<- u="">cbind
(nbReqSession[1],nbReqSession[2]/(endSession[2]-startSession[2])*60000)
testplanclean$nbuserlabel<-paste u="">testplanclean
$nbuser, " user: ",testplanclean$X1)

# Time elapsed per User and type of graph
timeElapsedGraph <- u="">ggplot
(testplanclean, aes(nbuserlabel,elapsed/1000,color=X1))
timeElapsedGraph + geom_boxplot() + labs(y="Temps de rponse (s)",x="Utilisateurs simultans")+ scale_x_discrete(labels=c(timeElapsedGraph$nbuser))

# Time elapsed per Filter
timeElapsedPerFilterGraph <- u="">ggplot
(testplanclean, aes(X3,elapsed/1000))
timeElapsedPerFilterGraph + stat_boxplot() + labs(y="Temps de rponse (s)",x="Type de filtre")

# Time elapsed per aircraft
timeElapsedPerAircraftGraph <- u="">ggplot
(testplanclean, aes(X2,elapsed/1000))
timeElapsedPerAircraftGraph + stat_boxplot() + labs(y="Temps de rponse (s)",x="Aircraft")

# Time elapsed  type of graph
timeElapsedGraph <- u="">ggplot
(testplanclean, aes(X1,elapsed/1000))
timeElapsedGraph + geom_boxplot() + labs(y="Temps de rponse (s)",x="Type of Graph")


hist(testplanclean$timeStamp/60000)

aggregate(x=testplan$responseCode,by=list(testplan$label,testplan$responseCode),FUN='length')


intensiteChart<- u="">ggplot
(intensite,aes(Group.1,x))+theme(axis.text.x=element_blank(),  axis.ticks.x=element_blank())
intensiteChart+geom_point()+geom_smooth(method="lm",color="Red")+labs(y="Request per minutes",x="Stress of the scenario")
intensite

Package pour traiter les dates
install.packages('lubridate')
library(lubridate)
access_log$Date<-dmy_hms access_log="" span="">


Aucun commentaire: