зеркало из https://github.com/mozilla/pluotsorbet.git
fix comments
replace tabs with spaces (indent 2) use real commandline flag to control install vs. run benchmark
This commit is contained in:
Родитель
99d22326b5
Коммит
d321ab9d09
|
@ -2,7 +2,7 @@
|
|||
|
||||
// prerequisites:
|
||||
|
||||
// set the pref security.turn_off_all_security_so_that_viruses_can_take_over_this_computer
|
||||
// on your phone, set the pref security.turn_off_all_security_so_that_viruses_can_take_over_this_computer
|
||||
// see https://wiki.mozilla.org/B2G/QA/Tips_And_Tricks#For_changing_the_preference:
|
||||
|
||||
// make clean && BENCHMARK=1 make package
|
||||
|
@ -25,10 +25,15 @@ var gBenchRunner = {};
|
|||
gBenchRunner.deviceClient = null;
|
||||
gBenchRunner.emulatorWebApp = null;
|
||||
gBenchRunner.pathToPackagedApp = args[2];
|
||||
gBenchRunner.install = false;
|
||||
|
||||
if (gBenchRunner.pathToPackagedApp == null) {
|
||||
console.log('usage: node benchrunner.js /path/to/packaged/app');
|
||||
process.exit(1);
|
||||
console.log('usage: node benchrunner.js /path/to/packaged/app [install]');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (args[3] && args[3] == 'install') {
|
||||
gBenchRunner.install = true;
|
||||
}
|
||||
|
||||
console.log('app package:', gBenchRunner.pathToPackagedApp);
|
||||
|
@ -42,122 +47,122 @@ gBenchRunner.manifest = JSON.parse(manifestString);
|
|||
// find the device, uninstall the old packaged app, install the new packaged app
|
||||
|
||||
function reinstallEmulatorApp(apps) {
|
||||
console.log('Found', apps.length, 'existing apps');
|
||||
console.log('Found', apps.length, 'existing apps');
|
||||
|
||||
return Promise.all(apps.map(function(app) {
|
||||
console.log('Uninstalling', app.manifestURL);
|
||||
return uninstallApp({ manifestURL: app.manifestURL, client: gBenchRunner.deviceClient })
|
||||
}))
|
||||
return Promise.all(apps.map(function(app) {
|
||||
console.log('Uninstalling', app.manifestURL);
|
||||
return uninstallApp({ manifestURL: app.manifestURL, client: gBenchRunner.deviceClient })
|
||||
}))
|
||||
|
||||
.then(function installEmulatorApp() {
|
||||
console.log('Installing');
|
||||
return installApp({
|
||||
// 3. install the new version
|
||||
appPath: gBenchRunner.pathToPackagedApp,
|
||||
client: gBenchRunner.deviceClient
|
||||
})
|
||||
})
|
||||
.then(function installEmulatorApp() {
|
||||
console.log('Installing');
|
||||
return installApp({
|
||||
// 3. install the new version
|
||||
appPath: gBenchRunner.pathToPackagedApp,
|
||||
client: gBenchRunner.deviceClient
|
||||
})
|
||||
})
|
||||
|
||||
.then(function finishInstallEmulatorApp(appId) {
|
||||
// 4. find the new version
|
||||
console.log('App installed', appId);
|
||||
.then(function finishInstallEmulatorApp(appId) {
|
||||
// 4. find the new version
|
||||
console.log('App installed', appId);
|
||||
|
||||
// TODO: this is rude from a Promises point of view.
|
||||
process.exit(0);
|
||||
});
|
||||
// TODO: this is rude from a Promises point of view.
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
// find the device, find, launch, and connect to the j2me app, connect to the console, run the benchmark
|
||||
|
||||
function benchmarkEmulatorApp(apps) {
|
||||
|
||||
gBenchRunner.emulatorWebApp = apps[0];
|
||||
gBenchRunner.emulatorWebApp = apps[0];
|
||||
|
||||
console.log('Found', gBenchRunner.emulatorWebApp.name, gBenchRunner.emulatorWebApp.manifestURL);
|
||||
console.log('Found', gBenchRunner.emulatorWebApp.name, gBenchRunner.emulatorWebApp.manifestURL);
|
||||
|
||||
return launchApp({
|
||||
client: gBenchRunner.deviceClient,
|
||||
manifestURL: gBenchRunner.emulatorWebApp.manifestURL
|
||||
})
|
||||
return launchApp({
|
||||
client: gBenchRunner.deviceClient,
|
||||
manifestURL: gBenchRunner.emulatorWebApp.manifestURL
|
||||
})
|
||||
|
||||
.then(function connectToAppConsoleAndRunTest(result) {
|
||||
console.log('Launched app', result);
|
||||
.then(function connectToAppConsoleAndRunTest(result) {
|
||||
console.log('Launched app', result);
|
||||
|
||||
gBenchRunner.deviceClient.getWebapps(function(err, webapps) {
|
||||
console.log('Getting webapp', gBenchRunner.emulatorWebApp.manifestURL);
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
gBenchRunner.deviceClient.getWebapps(function(err, webapps) {
|
||||
console.log('Getting webapp', gBenchRunner.emulatorWebApp.manifestURL);
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
webapps.getApp(gBenchRunner.emulatorWebApp.manifestURL, function (err, app) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
webapps.getApp(gBenchRunner.emulatorWebApp.manifestURL, function (err, app) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
app.Console.addListener('console-api-call', function(e) {
|
||||
var consoleLine = e.arguments[0];
|
||||
app.Console.addListener('console-api-call', function(e) {
|
||||
var consoleLine = e.arguments[0];
|
||||
|
||||
if (consoleLine.indexOf('bench: ') >= 0) {
|
||||
console.log(consoleLine);
|
||||
if (consoleLine.indexOf('bench: ') >= 0) {
|
||||
console.log(consoleLine);
|
||||
|
||||
if (consoleLine.indexOf('bench: done') >= 0) {
|
||||
// TODO: this is rude from a Promises point of view.
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (consoleLine.indexOf('bench: done') >= 0) {
|
||||
// TODO: this is rude from a Promises point of view.
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.Console.startListening();
|
||||
console.log('Listening to console');
|
||||
app.Console.startListening();
|
||||
console.log('Listening to console');
|
||||
|
||||
setTimeout(function () {
|
||||
app.Console.evaluateJS("cd(frames[0])", function(err, resp) {
|
||||
console.log('cd(frames[0])', err, resp);
|
||||
setTimeout(function () {
|
||||
app.Console.evaluateJS("cd(frames[0])", function(err, resp) {
|
||||
console.log('cd(frames[0])', err, resp);
|
||||
|
||||
app.Console.evaluateJS("Benchmark.start()", function(err, resp) {
|
||||
console.log('Started Benchmark', err, resp);
|
||||
});
|
||||
app.Console.evaluateJS("Benchmark.start()", function(err, resp) {
|
||||
console.log('Started Benchmark', err, resp);
|
||||
});
|
||||
|
||||
});
|
||||
}, 30000);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}, 30000);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Start process
|
||||
Promise.resolve().then(function() {
|
||||
findPorts()
|
||||
findPorts()
|
||||
|
||||
.then(function connectToDevice(results) {
|
||||
console.log('findPorts', results);
|
||||
return connect(results[0].port);
|
||||
})
|
||||
.then(function connectToDevice(results) {
|
||||
console.log('findPorts', results);
|
||||
return connect(results[0].port);
|
||||
})
|
||||
|
||||
.then(function connected(client) {
|
||||
console.log('Connected');
|
||||
.then(function connected(client) {
|
||||
console.log('Connected');
|
||||
|
||||
gBenchRunner.deviceClient = client;
|
||||
return client;
|
||||
})
|
||||
gBenchRunner.deviceClient = client;
|
||||
return client;
|
||||
})
|
||||
|
||||
.then(function findEmulatorApp(client) {
|
||||
// find the old version of this app
|
||||
return findApp({
|
||||
manifest: gBenchRunner.manifest,
|
||||
client: gBenchRunner.deviceClient
|
||||
})
|
||||
})
|
||||
.then(function findEmulatorApp(client) {
|
||||
// find the old version of this app
|
||||
return findApp({
|
||||
manifest: gBenchRunner.manifest,
|
||||
client: gBenchRunner.deviceClient
|
||||
})
|
||||
})
|
||||
|
||||
.then(function doTheThing(apps) {
|
||||
.then(function installOrRunBenchmark(apps) {
|
||||
|
||||
if (false) {
|
||||
return reinstallEmulatorApp(apps);
|
||||
} else {
|
||||
return benchmarkEmulatorApp(apps);
|
||||
}
|
||||
if (gBenchRunner.install) {
|
||||
return reinstallEmulatorApp(apps);
|
||||
} else {
|
||||
return benchmarkEmulatorApp(apps);
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче