-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathextLoader.ts
55 lines (42 loc) · 1.52 KB
/
extLoader.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"use strict";
export type PerfStats = {
loadStartTime: number;
loadEndTime?: number;
activationTime?: number;
load?: number;
activate?: number;
};
const perfStats: PerfStats = {
loadStartTime: Date.now()
};
// Object.defineProperty(exports, "__esModule", { value: true });
import { ExtensionContext } from 'vscode';
import {
activate as activateInternal,
deactivate as deactivateInternal
} from './extension';
// while this may load the code/references, it will be empty
import { ext } from './extensionVariables';
import { logger } from './logger';
async function activate(ctx: ExtensionContext) {
// we need to await this to complete so we can gather stats and log as needed
await activateInternal(ctx);
perfStats.activationTime = Date.now();
perfStats.activate = (perfStats.activationTime - perfStats.loadStartTime);
// now that the entire extension has loaded, we can actually call the following telemtry and logging functions and they work
ext.telemetry.capture({
command: "extensionActivation",
stats: perfStats
});
logger.info(`load stats: ${JSON.stringify(perfStats)}`);
return;
}
async function deactivate(ctx: any) {
await deactivateInternal(ctx);
console.log(`de-activation complete in ${Math.floor((Date.now() - perfStats.loadStartTime) / 1000 )}ms`);
return;
}
exports.activate = activate;
exports.deactivate = deactivate;
perfStats.loadEndTime = Date.now();
perfStats.load = (perfStats.loadEndTime - perfStats.loadStartTime);