未验证 提交 9b680b90 编写于 作者: M Méril 提交者: GitHub

feat(ui): fix wrong timings + resume editor to line number on load (#225)

上级 b707ef51
......@@ -34,7 +34,7 @@ $.fn.query = function () {
count: r.count,
timings: r.timings && {
...r.timings,
fetch: (Date.now() - time) * 1e6 - r.timings.execute,
fetch: (Date.now() - time) * 1e6,
},
})
......@@ -155,21 +155,25 @@ $.fn.domController = function () {
}
}
function roundTiming(time) {
return Math.round((time + Number.EPSILON) * 100) / 100
}
function formatTiming(nanos) {
if (nanos === 0) {
return "0"
}
if (nanos > 1e9) {
return `${Math.round(nanos / 1e9 + Number.EPSILON) / 100}s`
return `${roundTiming(nanos / 1e9)}s`
}
if (nanos > 1e6) {
return `${Math.round(nanos / 1e6 + Number.EPSILON) / 100}ms`
return `${roundTiming(nanos / 1e6)}ms`
}
if (nanos > 1e3) {
return `${Math.round(nanos / 1e3 + Number.EPSILON) / 100}μs`
return `${roundTiming(nanos / 1e3)}μs`
}
return `${nanos}ns`
......@@ -195,34 +199,34 @@ $.fn.domController = function () {
divMsg.html(`
<div class="query-result-value">
<div>
Execution time
Fetching time
</div>
<div>
${formatTiming(m.timings.execute)}
${formatTiming(m.timings.fetch)}
</div>
</div>
<div class="query-result-value">
<div>
Fetching time
Execution time
</div>
<div>
${formatTiming(m.timings.fetch)}
${formatTiming(m.timings.execute)}
</div>
</div>
<div class="query-result-value">
<div>
Compiling time
Counting time
</div>
<div>
${formatTiming(m.timings.compiler)}
${formatTiming(m.timings.count)}
</div>
</div>
<div class="query-result-value">
<div>
Counting time
Compiling time
</div>
<div>
${formatTiming(m.timings.count)}
${formatTiming(m.timings.compiler)}
</div>
</div>
${rows}
......@@ -314,7 +318,9 @@ $.fn.editor = function (msgBus) {
const col = localStorage.getItem(storeKeys.col)
if (row && col) {
edit.gotoLine(row, col)
setTimeout(() => {
edit.gotoLine(row, col)
}, 50)
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册