Skip to content

Commit

Permalink
Add detailed diagram loader initialize measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
tortmayr committed Dec 2, 2024
1 parent a460093 commit 59982d1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
33 changes: 29 additions & 4 deletions packages/editor/src/performance/perf-diagram-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DiagramLoader, DiagramLoadingOptions, IDiagramStartup, ResolvedDiagramLoadingOptions } from '@eclipse-glsp/client';
import { DiagramLoader, DiagramLoadingOptions, IDiagramStartup, ResolvedDiagramLoadingOptions, StatusAction } from '@eclipse-glsp/client';
import { injectable } from 'inversify';

@injectable()
Expand All @@ -10,9 +10,34 @@ export class PerfDiagramLoader extends DiagramLoader {
}

protected override async initialize(options: ResolvedDiagramLoadingOptions): Promise<void> {
console.time('DiagramLoader.initialize');
await super.initialize(options);
console.timeEnd('DiagramLoader.initialize');
console.time('DiagramLoader.initialize (DI)');
if (options.enableNotifications) {
console.time('dispatchStatus - (DI)');
await this.actionDispatcher.dispatch(StatusAction.create('Initializing...', { severity: 'INFO' }));
console.timeEnd('dispatchStatus - (DI)');
}

console.time('getClient - (DI)');
const glspClient = await this.options.glspClientProvider();
console.timeEnd('getClient - (DI)');
console.time('startClient - (DI)');
await glspClient.start();
console.timeEnd('startClient - (DI)');
if (!glspClient.initializeResult) {
console.time('initializeServer - (DI)');
await glspClient.initializeServer(options.initializeParameters);
console.timeEnd('initializeServer - (DI)');
}
console.time('configureModelSource - (DI)');
this.modelSource.configure(glspClient);
console.timeEnd('configureModelSource - (DI)');

if (options.enableNotifications) {
console.time('clearStatus - (DI)');
this.actionDispatcher.dispatch(StatusAction.create('', { severity: 'NONE' }));
console.timeEnd('clearStatus - (DI)');
}
console.timeEnd('DiagramLoader.initialize (DI)');
}

protected override async requestModel(options: ResolvedDiagramLoadingOptions): Promise<void> {
Expand Down
32 changes: 32 additions & 0 deletions packages/editor/src/performance/perf-model-source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Disposable, GLSPClient, GLSPModelSource } from '@eclipse-glsp/client';
import { injectable } from 'inversify';

@injectable()
export class PerfGLSPModelSource extends GLSPModelSource {
async configure(glspClient: GLSPClient): Promise<void> {
console.time('GLSPModelSource.configure (MS)');
this.glspClient = glspClient;
if (!glspClient.initializeResult) {
throw new Error('Could not configure model source. The GLSP client is not initialized yet!');
}

console.time('createInitializeClientSessionParameters (MS)');
const initializeParams = this.createInitializeClientSessionParameters(glspClient.initializeResult);
console.timeEnd('createInitializeClientSessionParameters (MS)');

console.time('configureServerActions (MS)');
this.configureServeActions(glspClient.initializeResult);
console.timeEnd('configureServerActions (MS)');

this.toDispose.push(
glspClient.onActionMessage(message => this.messageReceived(message), this.clientId),
Disposable.create(() => glspClient.disposeClientSession(this.createDisposeClientSessionParameters()))
);

console.time('initializeClientSession (MS)');
const result = await glspClient!.initializeClientSession(initializeParams);
console.timeEnd('initializeClientSession (MS)');
console.timeEnd('GLSPModelSource.configure (MS)');
return result;
}
}
4 changes: 3 additions & 1 deletion packages/editor/src/performance/performance-module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { DiagramLoader, FeatureModule, GLSPActionDispatcher, ModelViewer, TYPES } from '@eclipse-glsp/client';
import { DiagramLoader, FeatureModule, GLSPActionDispatcher, GLSPModelSource, ModelViewer, TYPES } from '@eclipse-glsp/client';
import { PerfActionDispatcher } from './perf-action-dispatcher';
import { PerfCommandStack } from './perf-command-stack';
import { PerfDiagramLoader } from './perf-diagram-loader';
import { PerfModelViewer } from './perf-viewer';
import { PerfGLSPModelSource } from './perf-model-source';

export function createPerformanceModule(enabled?: boolean): FeatureModule {
return new FeatureModule(
Expand All @@ -14,6 +15,7 @@ export function createPerformanceModule(enabled?: boolean): FeatureModule {
rebind(GLSPActionDispatcher).to(PerfActionDispatcher).inSingletonScope();
rebind(ModelViewer).to(PerfModelViewer).inSingletonScope();
rebind(TYPES.ICommandStack).to(PerfCommandStack).inSingletonScope();
rebind(GLSPModelSource).to(PerfGLSPModelSource).inSingletonScope();
},
{ featureId: Symbol('performance') }
);
Expand Down

0 comments on commit 59982d1

Please sign in to comment.