Skip to content

Commit

Permalink
Merge pull request #2134 from Likqez/master
Browse files Browse the repository at this point in the history
Test Report: Implement table sorting
  • Loading branch information
cyberw authored Jul 19, 2022
2 parents ea069f0 + 8709944 commit a37a9b2
Showing 1 changed file with 49 additions and 29 deletions.
78 changes: 49 additions & 29 deletions locust/templates/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ <h2>Request Statistics</h2>
<table class="stats">
<thead>
<tr>
<th>Method</th>
<th>Name</th>
<th># Requests</th>
<th># Fails</th>
<th>Average (ms)</th>
<th>Min (ms)</th>
<th>Max (ms)</th>
<th>Average size (bytes)</th>
<th>RPS</th>
<th>Failures/s</th>
<th class="sortable">Method</th>
<th class="sortable">Name</th>
<th class="sortable"># Requests</th>
<th class="sortable"># Fails</th>
<th class="sortable">Average (ms)</th>
<th class="sortable">Min (ms)</th>
<th class="sortable">Max (ms)</th>
<th class="sortable">Average size (bytes)</th>
<th class="sortable">RPS</th>
<th class="sortable">Failures/s</th>
</tr>
</thead>
<tbody>
Expand All @@ -90,16 +90,16 @@ <h2>Response Time Statistics</h2>
<table class="stats">
<thead>
<tr>
<th>Method</th>
<th>Name</th>
<th>50%ile (ms)</th>
<th>60%ile (ms)</th>
<th>70%ile (ms)</th>
<th>80%ile (ms)</th>
<th>90%ile (ms)</th>
<th>95%ile (ms)</th>
<th>99%ile (ms)</th>
<th>100%ile (ms)</th>
<th class="sortable">Method</th>
<th class="sortable">Name</th>
<th class="sortable">50%ile (ms)</th>
<th class="sortable">60%ile (ms)</th>
<th class="sortable">70%ile (ms)</th>
<th class="sortable">80%ile (ms)</th>
<th class="sortable">90%ile (ms)</th>
<th class="sortable">95%ile (ms)</th>
<th class="sortable">99%ile (ms)</th>
<th class="sortable">100%ile (ms)</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -127,10 +127,10 @@ <h2>Failures Statistics</h2>
<table class="stats">
<thead>
<tr>
<th>Method</th>
<th>Name</th>
<th>Error</th>
<th>Occurrences</th>
<th class="sortable">Method</th>
<th class="sortable">Name</th>
<th class="sortable">Error</th>
<th class="sortable">Occurrences</th>
</tr>
</thead>
<tbody>
Expand All @@ -153,10 +153,10 @@ <h2>Exceptions Statistics</h2>
<table>
<thead>
<tr>
<th>Count</th>
<th>Message</th>
<th>Traceback</th>
<th>Nodes</th>
<th class="sortable">Count</th>
<th class="sortable">Message</th>
<th class="sortable">Traceback</th>
<th class="sortable">Nodes</th>
</tr>
</thead>
<tbody>
Expand All @@ -183,7 +183,7 @@ <h2>Charts</h2>
<h2>Final ratio</h2>
<div class="tasks" data-tasks="{{ escape(tasks) }}"></div>
</div>

</div>

{# <script type="text/javascript" src="/static/jquery-1.11.3.min.js"></script> #}
Expand Down Expand Up @@ -238,5 +238,25 @@ <h2>Final ratio</h2>

fillTasksFromObj()
</script>

<script>
$('.sortable').click(function() {
var table = $(this).parents('table').eq(0)
var rowArray = table.find('tr:gt(0)').toArray()
var aggregatedRow = rowArray.pop()
var rows = rowArray.sort(comparer($(this).index()))
this.asc = !this.asc
if (!this.asc){rows = rows.reverse()}
for (var i = 0; i < rows.length; i++){table.append(rows[i])}
table.append(aggregatedRow)
})
function comparer(index) {
return function(a,b) {
var valA = getCellValue(a, index), valB = getCellValue(b, index)
return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB)
}
}
function getCellValue(row, index) { return $(row).children('td').eq(index).text() }
</script>
</body>
</html>

0 comments on commit a37a9b2

Please sign in to comment.