-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Measure actions when they are actually handled instead of on dispatch (avoids inconsistencies due to action queue blocking) Add in depth logging for set-model-command and model update
- Loading branch information
Showing
6 changed files
with
123 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CommandExecutionContext, GModelRoot, SetModelCommand } from '@eclipse-glsp/client'; | ||
import { injectable } from 'inversify'; | ||
|
||
@injectable() | ||
export class PerfSetModelCommand extends SetModelCommand { | ||
protected counter = 0; | ||
|
||
execute(context: CommandExecutionContext): GModelRoot { | ||
const counter = ++this.counter; | ||
console.time(`execute SetModelCommand (sc) ${counter}`); | ||
console.time(`sc-createOldRoot (${counter})`); | ||
this.oldRoot = context.modelFactory.createRoot(context.root); | ||
console.timeEnd(`sc-createOldRoot (${counter})`); | ||
console.time(`sc-createNewRoot (${counter})`); | ||
this.newRoot = context.modelFactory.createRoot(this.action.newRoot); | ||
console.timeEnd(`sc-createNewRoot (${counter})`); | ||
console.timeEnd(`execute SetModelCommand (sc) ${counter}`); | ||
|
||
return this.newRoot; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** @jsx html */ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import { Action, GModelRoot, ModelViewer, copyClassesFromElement, copyClassesFromVNode, html, setClass } from '@eclipse-glsp/client'; | ||
import { injectable } from 'inversify'; | ||
|
||
@injectable() | ||
export class PerfModelViewer extends ModelViewer { | ||
protected counter = 0; | ||
update(model: Readonly<GModelRoot>, cause?: Action): void { | ||
const counter = ++this.counter; | ||
console.time(`Viewer update (vu) (${counter})`); | ||
this.logger.log(this, 'rendering', model); | ||
console.time(`vu- renderElement (${counter})`); | ||
const newVDOM = <div id={this.options.baseDiv}>{this.renderer.renderElement(model)}</div>; | ||
console.timeEnd(`vu- renderElement (${counter})`); | ||
if (this.lastVDOM !== undefined) { | ||
const hadFocus = this.hasFocus(); | ||
console.time(`vu- copyClassesFromVNode (${counter})`); | ||
copyClassesFromVNode(this.lastVDOM, newVDOM); | ||
console.timeEnd(`vu- copyClassesFromVNode (${counter})`); | ||
console.time(`vu- patch vdom (${counter})`); | ||
this.lastVDOM = this.patcher.call(this, this.lastVDOM, newVDOM); | ||
console.timeEnd(`vu- patch vdom (${counter})`); | ||
console.time(`vu- restoreFocus (${counter})`); | ||
this.restoreFocus(hadFocus); | ||
console.timeEnd(`vu- restoreFocus (${counter})`); | ||
} else if (typeof document !== 'undefined') { | ||
let placeholder = null; | ||
if (this.options.shadowRoot) { | ||
const shadowRoot = document.getElementById(this.options.shadowRoot)?.shadowRoot; | ||
if (shadowRoot) { | ||
placeholder = shadowRoot.getElementById(this.options.baseDiv); | ||
} | ||
} else { | ||
placeholder = document.getElementById(this.options.baseDiv); | ||
} | ||
if (placeholder !== null) { | ||
if (typeof window !== 'undefined') { | ||
window.addEventListener('resize', () => { | ||
this.onWindowResize(newVDOM); | ||
}); | ||
} | ||
console.time(`vu- copyClassesFromElement (${counter})`); | ||
copyClassesFromElement(placeholder, newVDOM); | ||
setClass(newVDOM, this.options.baseClass, true); | ||
console.timeEnd(`vu- copyClassesFromElement (${counter})`); | ||
console.time(`vu- patch vdom (${counter})`); | ||
this.lastVDOM = this.patcher.call(this, placeholder, newVDOM); | ||
console.timeEnd(`vu- patch vdom (${counter})`); | ||
} else { | ||
this.logger.error(this, 'element not in DOM:', this.options.baseDiv); | ||
} | ||
} | ||
console.time(`vu- postUpdate (${counter})`); | ||
this.renderer.postUpdate(cause); | ||
console.timeEnd(`vu- postUpdate (${counter})`); | ||
console.timeEnd(`Viewer update (vu) (${counter})`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters