Add npmVersion command line argument to benchmark NPM versions (#7674)

* npmVersion CLIarg

* add readme description

---------

Co-authored-by: Linchenn <40653845+Linchenn@users.noreply.github.com>
Co-authored-by: Matthew Soulanille <msoulanille@google.com>
This commit is contained in:
wrighkv1 2023-05-30 13:56:51 -07:00 committed by GitHub
parent fd7fbaaa0d
commit 2cbc737417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -141,6 +141,11 @@ The following are supported options arguments which trigger options features:
``` shell
node app.js --localBuild=core,webgl,wasm,cpu,layers,converter,automl
```
* --npmVersion
- Specify the npm version of TFJS library to benchmark. By default the latest version of TFJS will be benchmarked.
``` shell
node app.js --npmVersion=4.4.0
```
## Custom model
The custom model is supported, but is constrained by:

View File

@ -284,9 +284,12 @@ function runBrowserStackBenchmark(tabId) {
if (cliArgs.localBuild) {
args.push(`--localBuild=${cliArgs.localBuild}`)
};
if (cliArgs.npmVersion) {
args.push(`--npmVersion=${cliArgs.npmVersion}`)
};
const command = `yarn ${args.join(' ')}`;
console.log(`Running: ${command}`);
execFile('yarn', args, { timeout: 3e5 }, (error, stdout, stderr) => {
if (error) {
console.log(`\n${error}`);
@ -417,6 +420,13 @@ function setupHelpMessage() {
default: '',
action: 'store'
});
parser.add_argument('--npmVersion', {
help: 'specify the npm version of TFJS library to benchmark.' +
'By default the latest version of TFJS will be benchmarked' +
'Example: --npmVersion=4.4.0.',
type: 'string',
action: 'store'
});
cliArgs = parser.parse_args();
console.dir(cliArgs);
}

View File

@ -66,7 +66,12 @@ module.exports = function(config) {
if (config.localBuild?.includes(name)) {
return `../../../dist/bin/${url}`;
} else {
return `https://unpkg.com/@tensorflow/${url.replace('/', '@latest/')}`;
if (config.npmVersion){
let version = config.npmVersion;
return `https://unpkg.com/@tensorflow/${url.replace('/', '@' + version + '/')}`;
} else {
return `https://unpkg.com/@tensorflow/${url.replace('/', '@latest/')}`;
}
}
});