2 min read

Plotting JMeter results

Next Compiling multiple JMeter runs into a single chart and report

JMeter is a powerful testing tool. R can be used to process the raw test logs from JMeter and generate the final product, Analysis and Reports.

The JMeter gui should only be used for design and dry run the test set. Actual test results should be taken from JMeter runs in headless mode.

jmeter -n -t "mytestset.jmx" -l "myapp_v0.1_results.csv"
tr <- list() # Test Report
tr$folder <- "/folder/containing/csv/data"
tr$current$contents <- read_csv(paste(tr$folder,"/myapp_v0.1_results.csv", sep=""))

JMeter CSV Log Format

# pivot the table so we can see all the column headers in a column
tibble(columnHeaders=colnames(tr$current$contents),
       exampleValue=unlist(tr$current$contents[1,], use.names = F)) %>%
       knitr::kable()
columnHeaders exampleValue
timeStamp 1593897999747
elapsed 178
label homepage
responseCode 200
responseMessage OK
threadName Stepping Thread Group - capacity testing 1-1
dataType text
success TRUE
failureMessage NA
bytes 1133
sentBytes 296
grpThreads 1
allThreads 1
URL http://localhost:5000/
Latency 173
IdleTime 0
Connect 106

This table shows a attribute called “elapsed”, with an example value of 178 which is in milliseconds (1000 ms = 1 sec).

Aggregate and Sort

tr$current$summary <-
  tr$current$contents %>%
  select(Endpoint = label, elapsed = elapsed) %>%
  group_by(Endpoint) %>%
  summarise(Average=mean(elapsed)) %>%
  arrange(desc(Average))

Plot

positions = rev(tr$current$summary$Endpoint)
ggplot(data = tr$current$summary,  aes(x=Endpoint, y=Average)) +
  geom_bar(stat="identity") + 
  scale_x_discrete(limits = positions) +
  coord_flip()