mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
vscode perf cli (#170953)
- add vscode-perf module - add script to run perfs
This commit is contained in:
committed by
GitHub
parent
91db8ea85f
commit
2a277f292a
73
scripts/code-perf.js
Normal file
73
scripts/code-perf.js
Normal file
@@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// @ts-check
|
||||
|
||||
const path = require('path');
|
||||
const perf = require('@vscode/vscode-perf');
|
||||
|
||||
const VSCODE_FOLDER = path.join(__dirname, '..');
|
||||
|
||||
async function main() {
|
||||
|
||||
const args = [...process.argv];
|
||||
|
||||
// get build arg from args
|
||||
let buildArgIndex = args.indexOf('--build');
|
||||
buildArgIndex = buildArgIndex === -1 ? args.indexOf('-b') : buildArgIndex;
|
||||
if (buildArgIndex === -1) {
|
||||
args.push('--build');
|
||||
args.push(getLocalCLIPath());
|
||||
} else {
|
||||
const exePath = args[buildArgIndex + 1];
|
||||
args.splice(buildArgIndex + 1, 1, getExePath(exePath));
|
||||
}
|
||||
|
||||
args.push('--folder');
|
||||
args.push(VSCODE_FOLDER);
|
||||
args.push('--file');
|
||||
args.push(path.join(VSCODE_FOLDER, 'package.json'));
|
||||
|
||||
await perf(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} buildPath
|
||||
* @returns {string}
|
||||
*/
|
||||
function getExePath(buildPath) {
|
||||
buildPath = path.normalize(path.resolve(buildPath));
|
||||
if (buildPath === path.normalize(getLocalCLIPath())) {
|
||||
return buildPath;
|
||||
}
|
||||
let relativeExePath;
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
relativeExePath = path.join('Contents', 'MacOS', 'Electron');
|
||||
break;
|
||||
case 'linux': {
|
||||
const product = require(path.join(buildPath, 'resources', 'app', 'product.json'));
|
||||
relativeExePath = product.applicationName;
|
||||
break;
|
||||
}
|
||||
case 'win32': {
|
||||
const product = require(path.join(buildPath, 'resources', 'app', 'product.json'));
|
||||
relativeExePath = `${product.nameShort}.exe`;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error('Unsupported platform.');
|
||||
}
|
||||
return buildPath.endsWith(relativeExePath) ? buildPath : path.join(buildPath, relativeExePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
function getLocalCLIPath() {
|
||||
return process.platform === 'win32' ? path.join(VSCODE_FOLDER, 'scripts', 'code-cli.bat') : path.join(VSCODE_FOLDER, 'scripts', 'code-cli.sh');
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user