Skip to content

Commit 831aacd

Browse files
authored
Send the client initialize time (#1199)
Signed-off-by: Sheng Chen <[email protected]>
1 parent cb8b206 commit 831aacd

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/daemon/processWatcher.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { promisify } from "util";
99
import * as vscode from "vscode";
1010
import { sendInfo } from "vscode-extension-telemetry-wrapper";
1111
import { LSDaemon } from "./daemon";
12+
import { activatingTimestamp } from "../extension";
1213
const execFile = promisify(cp.execFile);
1314

1415
interface IJdtlsMetadata {
@@ -59,6 +60,9 @@ export class ProcessWatcher {
5960
public monitor() {
6061
const id = setInterval(() => {
6162
this.upTime().then(seconds => {
63+
if (!this.lastHeartbeat && seconds) {
64+
this.sendClientInitializeTime(seconds);
65+
}
6266
this.lastHeartbeat = seconds;
6367
}).catch(_e => {
6468
clearInterval(id);
@@ -99,6 +103,23 @@ export class ProcessWatcher {
99103
});
100104
this.daemon.logWatcher.sendErrorAndStackOnCrash();
101105
}
106+
107+
/**
108+
* Send the time the client takes to initialize. This is the time between the
109+
* activation and the JVM process is launched.
110+
*/
111+
private sendClientInitializeTime(seconds: string) {
112+
const upTime = seconds.match(/\d+\.\d+/)?.toString();
113+
if (upTime) {
114+
let interval = Math.round(
115+
performance.now() - activatingTimestamp - parseFloat(upTime) * 1000
116+
);
117+
sendInfo("", {
118+
name: "client-initialize-time",
119+
message: interval.toString()
120+
});
121+
}
122+
}
102123
}
103124

104125

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import { showWelcomeWebview, WelcomeViewSerializer } from "./welcome";
2626

2727
let cleanJavaWorkspaceIndicator: string;
2828
let activatedTimestamp: number;
29+
export let activatingTimestamp: number;
2930

3031
export async function activate(context: vscode.ExtensionContext) {
32+
activatingTimestamp = performance.now();
3133
syncState(context);
3234
initializeTelemetry(context);
3335
// initialize exp service ahead of activation operation to make sure exp context properties are set.

0 commit comments

Comments
 (0)