Browse Source

added debug code to display how often mithril redraws

master
Youen Toupin 3 years ago
parent
commit
184f1cee33
  1. 5
      WebApp/src/layout.tsx
  2. 5
      WebApp/src/pages/dashboard/dashboard-page.tsx

5
WebApp/src/layout.tsx

@ -4,8 +4,11 @@ require("./layout.css");
export default class Layout { export default class Layout {
private menuActive = false; private menuActive = false;
private drawCount = 0;
view(vnode: m.Vnode) { view(vnode: m.Vnode) {
this.drawCount = this.drawCount + 1;
return [ return [
<nav class="navbar" role="navigation" aria-label="main navigation"> <nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand"> <div class="navbar-brand">
@ -16,6 +19,8 @@ export default class Layout {
<span aria-hidden="true"></span> <span aria-hidden="true"></span>
<span aria-hidden="true"></span> <span aria-hidden="true"></span>
</a> </a>
<span>{this.drawCount}</span>
</div> </div>
<div id="mainMenu" class={'navbar-menu ' + (this.menuActive ? 'is-active' : '')}> <div id="mainMenu" class={'navbar-menu ' + (this.menuActive ? 'is-active' : '')}>

5
WebApp/src/pages/dashboard/dashboard-page.tsx

@ -17,7 +17,10 @@ export class DashboardPage extends Page {
} }
async refresh() { async refresh() {
this.status = await MonitorApi.get().fetchStatus(); let newStatus = await MonitorApi.get().fetchStatus();
if(this.status == null)
m.redraw();
this.status = newStatus;
// todo: update widgets (avoiding to use m.redraw which is a bit costly on CPU) // todo: update widgets (avoiding to use m.redraw which is a bit costly on CPU)
if(this.autoRefresh) if(this.autoRefresh)
setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500); setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500);

Loading…
Cancel
Save