v0.0.5: API cleanup
This commit is contained in:
Родитель
04c8d2efd0
Коммит
39bc2243bb
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "flamegrill",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.5",
|
||||
"main": "lib/flamegrill.js",
|
||||
"module": "lib/flamegrill.js",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
// TODO: pass scenario data.. name, test URL, optional reference URL
|
||||
// TODO: use approach similar to jest.. config file with URL targets
|
||||
// TODO: recheck and remove unnecessary depedencies
|
||||
// TODO: filters should be custom defined with names and regex... can't assume using minified React. get rid of helpers?
|
||||
|
@ -15,14 +14,6 @@
|
|||
// * filters
|
||||
// * iterations / rollup
|
||||
|
||||
/*
|
||||
node .\bin\flamegrill.js -n SplitButtonNew -s "http://fabricweb.z5.web.core.windows.net/pr-deploy-site/refs/heads/master/perf-test/index.html?scenario=SplitButtonNew&iterations=5000"
|
||||
node .\bin\flamegrill.js -n SplitButtonNew -s "C:\git\oufr-jg\apps\perf-test\dist\index.html?scenario=SplitButtonNew&iterations=5000" -r "http://fabricweb.z5.web.core.windows.net/pr-deploy-site/refs/heads/master/perf-test/index.html?scenario=SplitButtonNew&iterations=5000" -o dist -t logfiles
|
||||
node .\bin\flamegrill.js -n SplitButtonNew -s "C:\Users\Jason\src\oufr-jg\apps\perf-test\dist\index.html?scenario=SplitButtonNew&iterations=5000" -r "http://fabricweb.z5.web.core.windows.net/pr-deploy-site/refs/heads/master/perf-test/index.html?scenario=SplitButtonNew&iterations=5000"
|
||||
node .\bin\flamegrill.js --name SplitButtonNew --scenario "C:\git\oufr-jg\apps\perf-test\dist\index.html?scenario=SplitButtonNew&iterations=5000" --reference "http://fabricweb.z5.web.core.windows.net/pr-deploy-site/refs/heads/master/perf-test/index.html?scenario=SplitButtonNew&iterations=5000" --out-dir out --temp-dir temp
|
||||
node .\bin\flamegrill.js -n SplitButtonNew -s "http://fabricweb.z5.web.core.windows.net/pr-deploy-site/refs/heads/master/perf-test/index.html?scenario=SplitButtonNew&iterations=5000" -o out -t temp
|
||||
*/
|
||||
|
||||
import { CliOptions } from './CliOptions';
|
||||
import flamegrill from './flamegrill';
|
||||
import parser from 'yargs-parser';
|
||||
|
@ -79,7 +70,7 @@ const options: CliOptions = {
|
|||
scenario,
|
||||
tempDir
|
||||
} = options;
|
||||
flamegrill( [{ name, scenario, reference }], { outDir, tempDir } );
|
||||
flamegrill.cook( [{ name, scenario, reference }], { outDir, tempDir } );
|
||||
break;
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -6,8 +6,6 @@ import generateFlamegraph from './flamegraph/generateFlamegraph';
|
|||
// Chrome command for running similarly configured instance of Chrome as puppeteer is configured here:
|
||||
// "C:\Program Files (x86)\Google\Chrome\Application\chrome" --no-sandbox --js-flags=" --logfile=C:\git\perf\output\chrome.log --prof --jitless --no-opt" --user-data-dir="C:\git\perf\user" http://localhost:4322
|
||||
|
||||
// TODO: reorganize to match cli.. export object with similarly named functions such as cook
|
||||
|
||||
export type Scenario = {
|
||||
name: string;
|
||||
scenario: string;
|
||||
|
@ -19,24 +17,23 @@ export type ScenarioConfig = {
|
|||
tempDir?: string;
|
||||
};
|
||||
|
||||
// TODO: rename / optionalize
|
||||
export interface ScenarioTest extends Scenario {
|
||||
logfileMaster?: string;
|
||||
outfileMaster: string;
|
||||
logfilePR: string;
|
||||
outfilePR: string;
|
||||
logfile: string;
|
||||
outfile: string;
|
||||
logfileReference?: string;
|
||||
outfileReference: string;
|
||||
};
|
||||
|
||||
export interface ScenarioAnalysis extends ScenarioTest {
|
||||
numTicksMaster?: number;
|
||||
numTicksPR?: number;
|
||||
numTicksReference?: number;
|
||||
numTicks?: number;
|
||||
};
|
||||
|
||||
export async function flamegrill(scenarios: Scenario[], config: ScenarioConfig) {
|
||||
export async function cook(scenarios: Scenario[], config: ScenarioConfig) {
|
||||
// const extraV8Flags = '--log-source-code --log-timer-events';
|
||||
// const extraV8Flags = '--log-source-code';
|
||||
const extraV8Flags = '';
|
||||
// TODO: test with no path, relative path, and absolute path
|
||||
|
||||
const outDir = config.outDir ? path.resolve(config.outDir) : process.cwd();
|
||||
const tempDir = config.tempDir ? path.resolve(config.tempDir) : process.cwd();
|
||||
const logFilePath = path.join(tempDir, '/puppeteer.log');
|
||||
|
@ -62,21 +59,21 @@ export async function flamegrill(scenarios: Scenario[], config: ScenarioConfig)
|
|||
const testResults: ScenarioTest[] = [];
|
||||
|
||||
for (const scenario of scenarios) {
|
||||
let logfilePR = await runPerfTest(browser, scenario.scenario, scenario.name, tempDir);
|
||||
let logfileMaster;
|
||||
let logfile = await runPerfTest(browser, scenario.scenario, scenario.name, tempDir);
|
||||
let logfileReference;
|
||||
if (scenario.reference) {
|
||||
logfileMaster = await runPerfTest(browser, scenario.reference, scenario.name, tempDir);
|
||||
logfileReference = await runPerfTest(browser, scenario.reference, scenario.name, tempDir);
|
||||
}
|
||||
|
||||
let outfileMaster = path.join(outDir, `${scenario.name}_master.html`);
|
||||
let outfilePR = path.join(outDir, `${scenario.name}_pr.html`);
|
||||
let outfileReference = path.join(outDir, `${scenario.name}_ref.html`);
|
||||
let outfile = path.join(outDir, `${scenario.name}.html`);
|
||||
|
||||
testResults.push({
|
||||
...scenario,
|
||||
logfileMaster,
|
||||
outfileMaster,
|
||||
logfilePR,
|
||||
outfilePR
|
||||
logfileReference,
|
||||
outfileReference,
|
||||
logfile,
|
||||
outfile
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -87,9 +84,9 @@ export async function flamegrill(scenarios: Scenario[], config: ScenarioConfig)
|
|||
|
||||
// Serialize a bunch of async generation of flamegraphs
|
||||
for (const result of testResults) {
|
||||
await generateFlamegraph(result.logfilePR, result.outfilePR);
|
||||
if(result.logfileMaster) {
|
||||
await generateFlamegraph(result.logfileMaster, result.outfileMaster);
|
||||
await generateFlamegraph(result.logfile, result.outfile);
|
||||
if(result.logfileReference) {
|
||||
await generateFlamegraph(result.logfileReference, result.outfileReference);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,15 +144,15 @@ function processResults(scenarioConfigs: ScenarioTest[]): ScenarioAnalysis[] {
|
|||
const scenarioResults: ScenarioAnalysis[] = [];
|
||||
|
||||
scenarioConfigs.forEach(scenarioConfig => {
|
||||
let numTicksMaster;
|
||||
let numTicksReference;
|
||||
if (scenarioConfig.reference) {
|
||||
numTicksMaster = getTicks(scenarioConfig.outfileMaster);
|
||||
numTicksReference = getTicks(scenarioConfig.outfileReference);
|
||||
}
|
||||
let numTicksPR = getTicks(scenarioConfig.outfilePR);
|
||||
let numTicks = getTicks(scenarioConfig.outfile);
|
||||
let scenarioResult: ScenarioAnalysis = {
|
||||
...scenarioConfig,
|
||||
numTicksMaster,
|
||||
numTicksPR
|
||||
numTicksReference,
|
||||
numTicks
|
||||
}
|
||||
scenarioResults.push(scenarioResult);
|
||||
});
|
||||
|
@ -211,4 +208,6 @@ function arr_diff(a1: string[], a2: string[]): string[] {
|
|||
return diff;
|
||||
}
|
||||
|
||||
export default flamegrill;
|
||||
export default {
|
||||
cook
|
||||
};
|
Загрузка…
Ссылка в новой задаче