[PYTHON] Analyze JMeter jtl files using pandas

background

I am doing load tests and performance evaluations with JMeter, but since it is troublesome to open the output jtl file in JMeter's GUI mode one by one, I will calculate it with pandas.

Operation confirmed version

python 2.7.11 JMeter 3.1

Run JMeter and get jtl files

Execute JMeter in command mode as shown below and get the jtl file (csv format).

jmeter.bat -n -t test.jmx -l result.jtl

Statistic calculation example

Reading jtl files and calculating simple statistics

With csv format, it is easy because it can be converted to DataFrame format with one line.

import pandas as pd
#Read jtl file
df = pd.read_csv(jtl_file_name)

#Extraction of target column(Here, the start time and the elapsed time)
df = df.loc[:, ['timeStamp', 'elapsed']]
#Total number of threads
cnt = len(df.index)
#minimum value
min = df['elapsed'].min()
#Maximum value
max = df['elapsed'].max()
#Average value
avg = df['elapsed'].mean()
#standard deviation
std = df['elapsed'].std(ddof=False)

Throughput (# / sec) calculation

Divide the total number of threads by the time taken for the entire process. I referred to the following. https://jmeter.apache.org/usermanual/glossary.html

#Add the start time and elapsed time of each thread and add it as a new column to get the end time.
df['end_time'] = df['timeStamp'] + df['elapsed']
#Get the minimum start time
start = df['timeStamp'].min()
#Get the maximum end time
end = df['end_time'].max()
#Divide the total number of threads by the time taken for the entire process. Multiply 1000 for seconds.
tp = float(cnt)*1000.0/(end - start)

Impressions

pandas convenient. I think it is possible to collect statistics for each process by group by, but this time it is unnecessary, so I will not do it. Since the processing is slow for a moment, I feel that it is a little exaggerated for what I want to do, but considering the degree of freedom and expandability, the merit is great.

Recommended Posts

Analyze JMeter jtl files using pandas
[Python] Loading csv files using pandas
Cross tabulation using Pandas
Combine multiple Excel files loaded using pandas into one
Analyze stock prices using pandas data aggregation and group operations
Draw multiple graphs using Pandas
Data analysis using python pandas