mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
refine "workspace.stats.metadata" (#214000)
This commit is contained in:
parent
f444002632
commit
95b4682f72
|
@ -79,8 +79,9 @@ export interface WorkspaceStats {
|
|||
configFiles: WorkspaceStatItem[];
|
||||
fileCount: number;
|
||||
maxFilesReached: boolean;
|
||||
totalScanTime: number;
|
||||
launchConfigFiles: WorkspaceStatItem[];
|
||||
totalScanTime: number;
|
||||
totalReaddirCount: number;
|
||||
}
|
||||
|
||||
export interface PerformanceInfo {
|
||||
|
|
|
@ -61,11 +61,13 @@ export async function collectWorkspaceStats(folder: string, filter: string[]): P
|
|||
|
||||
const MAX_FILES = 20000;
|
||||
|
||||
function collect(root: string, dir: string, filter: string[], token: { count: number; maxReached: boolean }): Promise<void> {
|
||||
function collect(root: string, dir: string, filter: string[], token: { count: number; maxReached: boolean; readdirCount: number }): Promise<void> {
|
||||
const relativePath = dir.substring(root.length + 1);
|
||||
|
||||
return Promises.withAsyncBody(async resolve => {
|
||||
let files: IDirent[];
|
||||
|
||||
token.readdirCount++;
|
||||
try {
|
||||
files = await pfs.readdir(dir, { withFileTypes: true });
|
||||
} catch (error) {
|
||||
|
@ -131,7 +133,7 @@ export async function collectWorkspaceStats(folder: string, filter: string[]): P
|
|||
}
|
||||
|
||||
const statsPromise = Promises.withAsyncBody<WorkspaceStats>(async (resolve) => {
|
||||
const token: { count: number; maxReached: boolean } = { count: 0, maxReached: false };
|
||||
const token: { count: number; maxReached: boolean; readdirCount: number } = { count: 0, maxReached: false, readdirCount: 0 };
|
||||
const sw = new StopWatch(true);
|
||||
await collect(folder, folder, filter, token);
|
||||
const launchConfigs = await collectLaunchConfigs(folder);
|
||||
|
@ -140,8 +142,9 @@ export async function collectWorkspaceStats(folder: string, filter: string[]): P
|
|||
fileTypes: asSortedItems(fileTypes),
|
||||
fileCount: token.count,
|
||||
maxFilesReached: token.maxReached,
|
||||
launchConfigFiles: launchConfigs,
|
||||
totalScanTime: sw.elapsed(),
|
||||
launchConfigFiles: launchConfigs
|
||||
totalReaddirCount: token.readdirCount
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -578,13 +581,15 @@ export class DiagnosticsService implements IDiagnosticsService {
|
|||
duration: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'How did it take to make workspace stats' };
|
||||
reachedLimit: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Did making workspace stats reach its limits' };
|
||||
fileCount: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'How many files did workspace stats discover' };
|
||||
readdirCount: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'How many readdir call were needed' };
|
||||
};
|
||||
type WorkspaceStatsMetadata = {
|
||||
duration: number;
|
||||
reachedLimit: boolean;
|
||||
fileCount: number;
|
||||
readdirCount: number;
|
||||
};
|
||||
this.telemetryService.publicLog2<WorkspaceStatsMetadata, WorkspaceStatsMetadataClassification>('workspace.stats.metadata', { duration: stats.totalScanTime, reachedLimit: stats.maxFilesReached, fileCount: stats.fileCount });
|
||||
this.telemetryService.publicLog2<WorkspaceStatsMetadata, WorkspaceStatsMetadataClassification>('workspace.stats.metadata', { duration: stats.totalScanTime, reachedLimit: stats.maxFilesReached, fileCount: stats.fileCount, readdirCount: stats.totalReaddirCount });
|
||||
} catch {
|
||||
// Report nothing if collecting metadata fails.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue