Skip to content

Commit

Permalink
[VSC-6] Add benchmark init
Browse files Browse the repository at this point in the history
  • Loading branch information
krendelhoff2 committed Feb 24, 2025
1 parent f177cce commit affb7f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"package": "npm run generate && vsce package && npm test && npm run --silent lint",
"publish": "vsce publish",
"compile:benchmark-did-change": "npm run compile && esbuild ./src/server/bench/benchmark-did-change.ts --bundle --outfile=out/benchmark-did-change.js --external:vscode --format=cjs --platform=node --minify",
"compile:benchmark-init": "npm run compile && esbuild ./src/server/bench/benchmark-init.ts --bundle --outfile=out/benchmark-init.js --external:vscode --format=cjs --platform=node --minify",
"compile:dev": "npm run compile:pre && run-p compile:snippets compile:formatter compile:rust_ && run-p compile:motoko:dev",
"compile:motoko:dev": "esbuild motoko --bundle --outfile=out/motoko.js --format=cjs --platform=node --minify=false --sourcemap=inline && shx cp -r src/server/compiler out/compiler",
"compile:benchmark:dev": "npm run compile:dev && esbuild ./src/server/bench/benchmark.ts --bundle --outfile=out/benchmark.js --external:vscode --format=cjs --platform=node --minify=false --sourcemap=inline"
Expand Down
22 changes: 22 additions & 0 deletions src/server/bench/benchmark-init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { InitializeResult } from 'vscode-languageserver/node';
import {
clientInitParams,
createBenchmark,
logInitializationTiming,
Setup,
} from './helpers';

createBenchmark('init', async (setup: Setup) => {
const before = performance.now();

setup.client.onNotification('custom/initialized', (_) =>
logInitializationTiming(before),
);

await setup.benchmark<InitializeResult>(
'initialize',
clientInitParams(setup.rootUri),
);

await setup.sendNotification('initialized', {});
});

0 comments on commit affb7f6

Please sign in to comment.