Skip to content

Commit

Permalink
Merge pull request #70518 from Microsoft/roblou/avoid-slow-stats
Browse files Browse the repository at this point in the history
Fix #70045 by reverting some of #67269
  • Loading branch information
roblourens authored Mar 14, 2019
2 parents e64cb27 + a7b37c0 commit 999596a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/vs/base/node/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function collectLaunchConfigs(folder: string): Promise<WorkspaceStatItem[
});
}

export async function collectWorkspaceStats(folder: string, filter: string[]): Promise<WorkspaceStats> {
export function collectWorkspaceStats(folder: string, filter: string[]): Promise<WorkspaceStats> {
const configFilePatterns = [
{ 'tag': 'grunt.js', 'pattern': /^gruntfile\.js$/i },
{ 'tag': 'gulp.js', 'pattern': /^gulpfile\.js$/i },
Expand Down
43 changes: 1 addition & 42 deletions src/vs/workbench/contrib/stats/node/workspaceStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspa
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { joinPath } from 'vs/base/common/resources';
import { collectWorkspaceStats, WorkspaceStats as WorkspaceStatsType } from 'vs/base/node/stats';

const SshProtocolMatcher = /^([^@:]+@)?([^:]+):/;
const SshUrlMatcher = /^([^@:]+@)?([^:]+):(.+)$/;
Expand Down Expand Up @@ -226,15 +225,10 @@ export class WorkspaceStats implements IWorkbenchContribution {

private report(): void {

// Workspace Tags
// Workspace Stats
this.resolveWorkspaceTags(this.windowService.getConfiguration(), rootFiles => this.handleWorkspaceFiles(rootFiles))
.then(tags => this.reportWorkspaceTags(tags), error => onUnexpectedError(error));

// Workspace file types, config files, and launch configs
this.getWorkspaceMetadata().then(stats => {
this.reportWorkspaceMetadata(stats);
});

// Cloud Stats
this.reportCloudStats();

Expand Down Expand Up @@ -741,39 +735,4 @@ export class WorkspaceStats implements IWorkbenchContribution {
this.telemetryService.publicLog('resolveProxy.stats', { type });
}).then(undefined, onUnexpectedError);
}

/* __GDPR__
"workspace.metadata" : {
"fileTypes" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"configTypes" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
"launchConfigs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
}
*/
private reportWorkspaceMetadata(stats: WorkspaceStatsType[]): void {
for (let stat of stats) { // one event for each root folder in the workspace
this.telemetryService.publicLog('workspace.metadata', {
'fileTypes': stat.fileTypes,
'configTypes': stat.configFiles,
'launchConfigs': stat.launchConfigFiles
});
}
}

private getWorkspaceMetadata(): Promise<WorkspaceStatsType[]> {
const workspaceStatPromises: Promise<WorkspaceStatsType>[] = [];
const workspace = this.contextService.getWorkspace();
workspace.folders.forEach(folder => {
const folderUri = URI.revive(folder.uri);
if (folderUri.scheme === 'file') {
const folder = folderUri.fsPath;
workspaceStatPromises.push(collectWorkspaceStats(folder, ['node_modules', '.git']).then(async stats => {
return stats;
}));
}
});

return Promise.all(workspaceStatPromises).then((stats) => {
return stats;
});
}
}

0 comments on commit 999596a

Please sign in to comment.