From fd6e088a7eb2892b329aef2b46720acc8c688453 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 27 Mar 2022 00:52:55 +0000 Subject: [PATCH] Tidy up some background stuff --- src/static/js/SystemQueryClient.mjs | 17 ++++++++++++++--- src/static/js/misc/null.mjs | 4 ++++ src/static/js/ui/TableView.mjs | 5 +---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/static/js/SystemQueryClient.mjs b/src/static/js/SystemQueryClient.mjs index 9ad3873..b7426bd 100644 --- a/src/static/js/SystemQueryClient.mjs +++ b/src/static/js/SystemQueryClient.mjs @@ -1,5 +1,7 @@ "use strict"; +import pretty_ms from 'pretty-ms'; + import { once } from './misc/events.mjs'; class SystemQueryClient { @@ -20,15 +22,24 @@ class SystemQueryClient { abort.abort(); }, { once: true }); + const timings = [{ id: null, hostname: Symbol("START"), timing: `+0ms` }]; + const start = new Date(); let count = 0; while(source.readyState !== EventSource.CLOSED) { - let item = await once(source, "table", abort.signal); + const item = await once(source, "table", abort.signal); if(item.type === "abort") break; - yield JSON.parse(item.data); + const item_parsed = JSON.parse(item.data); + timings.push({ + id: item_parsed.peer.id.substring(0, 7), + hostname: item_parsed.peer.name, + timing: `+${pretty_ms(new Date() - start)}` + }); + yield item_parsed; count++; } - console.log(`FETCH TABLE ${table_name}: ${count} items returned`); + console.log(`FETCH TABLE ${table_name}: ${count} items returned in ${pretty_ms(new Date() - start)}`); + console.table(timings); } async fetch_json(path) { diff --git a/src/static/js/misc/null.mjs b/src/static/js/misc/null.mjs index 17416fb..0bba89e 100644 --- a/src/static/js/misc/null.mjs +++ b/src/static/js/misc/null.mjs @@ -1,2 +1,6 @@ "use strict"; +/** + * Used in esbuild to blackhole core Node.js modules that + * dependencies import. + */ export default null; diff --git a/src/static/js/ui/TableView.mjs b/src/static/js/ui/TableView.mjs index aa504f6..0666404 100644 --- a/src/static/js/ui/TableView.mjs +++ b/src/static/js/ui/TableView.mjs @@ -3,7 +3,6 @@ import Emel from 'emel'; import fa_emel from './forkawesome_emel.mjs'; -import AbstractUIItem from './AbstractUIItem.mjs'; import ui_item_index from './ui_item_index.mjs'; import tabledefs from '../tabledefs/index.mjs'; @@ -43,11 +42,9 @@ class TableView { let el = document.createElement("div"); el.classList.add("data-item"); - console.log(ui_item_index[def.type]); if(typeof ui_item_index[def.type] !== "undefined") { let item_manager = new ui_item_index[def.type](el, def); this.el_parts.set(def.name, item_manager); - console.log(`TableView:UIItem create`, item_manager); } else { console.warn(`Unknown item definition type '${def.type}', ignoring. This is probably a bug.`, def); @@ -85,7 +82,7 @@ class TableView { * @return {void} */ append_table(peer, table) { - console.log(`TableView:append PEER`, peer, `TABLE`, table); + // console.log(`TableView:append PEER`, peer, `TABLE`, table); for(let [ def_name, item_manager ] of this.el_parts) { if(item_manager === null) continue; item_manager.append(peer, table);