diff --git a/www/queries.tmpl b/www/queries.tmpl index 3d87342f7..776e4c519 100644 --- a/www/queries.tmpl +++ b/www/queries.tmpl @@ -270,8 +270,6 @@ command line parameter.

State # rows fetched Resource Pool - Coordinator Slots - Executor Slots Statement Delete diff --git a/www/query_plan_text.tmpl b/www/query_plan_text.tmpl index 4797f876c..15b75d20c 100644 --- a/www/query_plan_text.tmpl +++ b/www/query_plan_text.tmpl @@ -39,7 +39,7 @@ if (window.location.search.includes("imported")) { if (alert_message) { alert_message.remove(); } - const nav_links = document.getElementsByClassName("nav nav-tabs")[0]; + let nav_links = document.getElementsByClassName("nav nav-tabs")[0]; nav_links = nav_links.getElementsByClassName("nav-link"); for (let i = 0; i < nav_links.length;) { if (supported_tabs.includes(nav_links[i].textContent)) { diff --git a/www/query_profile.tmpl b/www/query_profile.tmpl index d21ff5e68..a9351f706 100644 --- a/www/query_profile.tmpl +++ b/www/query_profile.tmpl @@ -54,6 +54,54 @@ let db; const supported_tabs = ["Query", "Timeline", "Text plan", "Profile"]; +function formatNanoseconds(ns) { + const NS_IN_US = 1_000; + const NS_IN_MS = 1_000_000; + const NS_IN_SEC = 1_000_000_000; + const NS_IN_MIN = 60 * NS_IN_SEC; + const NS_IN_HOUR = 60 * NS_IN_MIN; + + let remaining = ns; + const parts = []; + + const hours = Math.floor(remaining / NS_IN_HOUR); + if (hours > 0) { + parts.push(`${hours}h`); + remaining %= NS_IN_HOUR; + } + + const minutes = Math.floor(remaining / NS_IN_MIN); + if (minutes > 0) { + parts.push(`${minutes}m`); + remaining %= NS_IN_MIN; + } + + const seconds = Math.floor(remaining / NS_IN_SEC); + if (parts.length < 2 && seconds > 0) { + parts.push(`${seconds}s`); + remaining %= NS_IN_SEC; + } + + const milliseconds = Math.floor(remaining / NS_IN_MS); + if (parts.length < 2 && milliseconds > 0) { + parts.push(`${milliseconds}ms`); + remaining %= NS_IN_MS; + } + + const microseconds = Math.floor(remaining / NS_IN_US); + if (parts.length < 2 && microseconds > 0) { + parts.push(`${microseconds}us`); + remaining %= NS_IN_US; + } + + if (parts.length < 2 && remaining > 0) { + parts.push(`${remaining}ns`); + } + + // If input was 0 ns + return parts.length ? parts.join('') : '0ns'; +} + function profileToString(profile, indent="") { let info_strings = ""; if (profile.info_strings) { @@ -68,7 +116,7 @@ function profileToString(profile, indent="") { event_sequences = `${event_sequences}${indent} Offset: ${eventSeq.offset}\n`; event_sequences = `${event_sequences}${indent} Events:\n`; eventSeq.events.forEach(event => { - event_sequences = `${event_sequences}${indent} ${event.label}: ${new Date(event.timestamp).toISOString()}\n`; + event_sequences = `${event_sequences}${indent} ${event.label}: ${formatNanoseconds(event.timestamp)}\n`; }); }); } @@ -98,7 +146,7 @@ if (window.location.search.includes("imported")) { if (alert_message) { alert_message.remove(); } - const nav_links = document.getElementsByClassName("nav nav-tabs")[0]; + let nav_links = document.getElementsByClassName("nav nav-tabs")[0]; nav_links = nav_links.getElementsByClassName("nav-link"); for (let i = 0; i < nav_links.length;) { if (supported_tabs.includes(nav_links[i].textContent)) { diff --git a/www/query_stmt.tmpl b/www/query_stmt.tmpl index 5756a8dff..391f657ce 100644 --- a/www/query_stmt.tmpl +++ b/www/query_stmt.tmpl @@ -49,7 +49,7 @@ if (window.location.search.includes("imported")) { if (alert_message) { alert_message.remove(); } - const nav_links = document.getElementsByClassName("nav nav-tabs")[0]; + let nav_links = document.getElementsByClassName("nav nav-tabs")[0]; nav_links = nav_links.getElementsByClassName("nav-link"); for (let i = 0; i < nav_links.length;) { if (supported_tabs.includes(nav_links[i].textContent)) { diff --git a/www/query_timeline.tmpl b/www/query_timeline.tmpl index 3c39c9cc2..8c14703d6 100644 --- a/www/query_timeline.tmpl +++ b/www/query_timeline.tmpl @@ -200,7 +200,7 @@ if (window.location.search.includes("imported")) { if (alert_message) { alert_message.remove(); } - const nav_links = document.getElementsByClassName("nav nav-tabs")[0]; + let nav_links = document.getElementsByClassName("nav nav-tabs")[0]; nav_links = nav_links.getElementsByClassName("nav-link"); for (let i = 0; i < nav_links.length;) { if (supported_tabs.includes(nav_links[i].textContent)) {