Use Math.round, only use ms in graphs when at least 10 ms

Math.round is about 99% faster https://jsperf.com/math-round-vs-tofixed2/17

Graph change tries to avoid rising/falling graphs while displayed values don't change
pull/645/head
Patrick Fruh 2020-06-09 20:17:41 +02:00
parent a8fb5ce80e
commit 0d350fb023
4 changed files with 10 additions and 10 deletions

View File

@ -130,10 +130,10 @@
let ts = w.globals.seriesX[seriesIndex][dataPointIndex];
const dt = new Date(ts).toLocaleDateString("en-us", timeoptions)
let val = series[seriesIndex][dataPointIndex];
if (val >= 1000) {
val = (val / 1000).toFixed(0) + " ms"
if (val >= 10000) {
val = Math.round(val / 1000) + " ms"
} else {
val = (val).toFixed(0) + " μs"
val = val + " μs"
}
return `<div class="chartmarker"><span>Response Time: </span><span class="font-3">${val}</span><span>${dt}</span></div>`
},

View File

@ -55,10 +55,10 @@
let ts = w.globals.seriesX[seriesIndex][dataPointIndex];
const dt = new Date(ts).toLocaleDateString("en-us", timeoptions)
let val = series[seriesIndex][dataPointIndex];
if (val >= 1000) {
val = (val / 1000).toFixed(0) + " ms"
if (val >= 10000) {
val = Math.round(val / 1000) + " ms"
} else {
val = (val).toFixed(0) + " μs"
val = val + " μs"
}
return `<div class="chartmarker"><span>Average Response Time: </span><span class="font-3">${val}</span><span>${dt}</span></div>`
},

View File

@ -169,7 +169,7 @@ export default Vue.mixin({
if (val >= 1000) {
return Math.round(val / 1000) + " ms"
}
return Math.round(val) + " μs"
return val + " μs"
},
firstDayOfMonth(date) {
return startOfMonth(date)

View File

@ -269,10 +269,10 @@ export default {
let ts = w.globals.seriesX[seriesIndex][dataPointIndex];
const dt = new Date(ts).toLocaleDateString("en-us", timeoptions)
let val = series[seriesIndex][dataPointIndex];
if (val >= 1000) {
val = (val / 1000).toFixed(0) + " ms"
if (val >= 10000) {
val = Math.round(val / 1000) + " ms"
} else {
val = (val).toFixed(0) + " μs"
val = val + " μs"
}
return `<div class="chartmarker"><span>Response Time: </span><span class="font-3">${val}</span><span>${dt}</span></div>`
},