How to change JMeter HTML Report’s Response Time values in Seconds?

Time Format in Seconds JMeter Dashboard Report

By default, JMeter HTML Dashboard Report represents the time in millisecond. For a web service test report, it is good to show the response time in milliseconds because their response time is less. Apart from this a web application usually has response time greater than one second, so to represent the figures in thousand (i.e. milliseconds) is visually not correct. Even in daily life, we use ‘Second’ as the smallest unit of time; not milliseconds. Hence it is a good practice to change and represent the response time in JMeter HTML Report in the format of ‘Second’ instead of ‘Millisecond’.

Default JMeter HTML Dashboard Report time format:

JMeter HTML Dashboard Report (time in millisecond format)
Figure 01: JMeter HTML Dashboard Report (time in millisecond format)

Many times it becomes troublesome or extra work to convert these values from milliseconds to seconds and then show them to Client or Stockholder in final reporting. Client and Stakeholders also do not prefer values in milliseconds and they ask for values in seconds for better understanding.

Steps to change the response time value into second in HTML report:

Step 1: Go to bin -> report-template -> content -> js folder inside the JMeter directory.

dashboard-js-fmkr file in JMeter
Figure 02: dasboard.js.fmkr File

Step 2: Open file “dashboard.js.fmkr” using Notepadd++.  An illustration is shown below:

Step 3: Search for the lines cell.innerHTML = “Response Times (ms)”; as illustrated below:

Figure 02: dashboard.js.fmkr File (Before Changes)

Step 4: Change ms to Sec, e.g.:- cell.innerHTML = “Response Times (Sec)”; as illustrated below:

JMeter Dashboard JS File after changes
Figure 03: dashboard.js.fmkr File (After Changes)

Step 5: Next, Find the line // Create statistics table. There will be some values under “switch” loop, as illustrated below:

JMeter Dashboard JS File Create Statistics Table
Figure 04: ‘Create Statistics Table’ section

Step 6: Replace the lines from switch(index) to return item;  by below lines:

            // Errors pct, 3rd Column
            case 3:
                	item = item.toFixed(2) + '%';
            // Average, 4th Column
            case 4:
		item = (item/1000).toFixed(2);
	// Min, 5th Column
            case 5:
		item = (item/1000).toFixed(2);
	// Max, 6th Column
            case 6:
		item = (item/1000).toFixed(2);
            // 90th pct, 7th Column
            case 7:
		item = (item/1000).toFixed(2);
	// 95th pct, 8th Column
            case 8:
		item = (item/1000).toFixed(2);
	// 99th pct, 9th Column
            case 9:
		item = (item/1000).toFixed(2);
            case 10:
            // Throughput
            case 11:
            // Kbytes/s
            case 12:
            // Sent Kbytes/s
               	 item = item.toFixed(2);
        return item;

Explanation of changes:

Each case number represents a column of Statistics Table in HTML Report:

Case 3 is for 3rd Column, i.e. Error%
Case 4 is for 4th Column, i.e. Average
Case 5 is for 5th Column, i.e. Min
Case 6 is for 6th Column, i.e. Max
Case 7 is for 7th Column, i.e. 90th pct
Case 8 is for 8th Column, i.e. 95th pct
Case 9 is for 9th Column, i.e. 99th pct. Case 10, Case 11 and Case 12 are for last 3 Columns respectively

Step 7: Save the file and restart the JMeter.

Step 8: Run the test and open the report. The values will be coming in Seconds, as illustrated below:

You may be interested:

  1. Free JMeter Tutorial
  2. JMeter Tips and Tricks

Leave a Reply

Your email address will not be published. Required fields are marked *