Skip to content

Commit

Permalink
Simplify number formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
andylibrian committed Apr 6, 2021
1 parent 726ff44 commit cd588d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/server/statik/statik.go

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions web/src/components/result_summary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<div class="card-content">
<div class="columns">
<div class="column">
<span class="title">{{ setThousandSeparator(Math.floor(summary.throughput)) }}</span>
<p class="content">response / seconds</p>
<span class="title">{{ formatNumber(Math.floor(summary.throughput)) }}</span>
<p class="content">responses / second</p>
</div>
<div class="column has-text-right is-one-fifth m-1">
<span class="icon is-large"><i class="fas fa-space-shuttle fa-3x"></i></span>
Expand All @@ -16,7 +16,7 @@
<div class="card-footer">
<div class="card-footer-item has-text-left">
<div class="content">
Total requests: <strong>{{ setThousandSeparator(summary.requests) }}</strong>
Total requests: <strong>{{ formatNumber(summary.requests) }}</strong>
</div>
</div>
</div>
Expand Down Expand Up @@ -63,13 +63,13 @@
</div>
<div class="card-footer">
<div class="card-footer-item has-text-left">
2xx:&nbsp;<strong>{{ setThousandSeparator(summary.statusCodes['2xx']) }}</strong>
2xx:&nbsp;<strong>{{ formatNumber(summary.statusCodes['2xx']) }}</strong>
</div>
<div class="card-footer-item has-text-left">
4xx:&nbsp;<strong>{{ setThousandSeparator(summary.statusCodes['4xx']) }}</strong>
4xx:&nbsp;<strong>{{ formatNumber(summary.statusCodes['4xx']) }}</strong>
</div>
<div class="card-footer-item has-text-left">
5xx:&nbsp;<strong>{{ setThousandSeparator(summary.statusCodes['5xx']) }}</strong>
5xx:&nbsp;<strong>{{ formatNumber(summary.statusCodes['5xx']) }}</strong>
</div>
</div>
</div>
Expand Down Expand Up @@ -115,8 +115,8 @@ export default {
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
},
setThousandSeparator(value){
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
formatNumber(value){
return value.toLocaleString()
}
}
}
Expand Down

0 comments on commit cd588d0

Please sign in to comment.