New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve benchmarks accuracy #148
Changes from 8 commits
827a835
4fa81c5
245306e
aee567a
a8c3740
0449171
069ba34
4c4c10f
d051c44
4ee5860
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -507,7 +507,12 @@ module.exports = ({ types: t }) => { | |
}, | ||
|
||
Function: { | ||
exit(path) { | ||
exit(path, state) { | ||
const multiPass = state.opts.multiPass === false ? false : true; | ||
if (!multiPass) { | ||
return; | ||
} | ||
|
||
earlyReturnTransform(path); | ||
|
||
if (!path.node[shouldRevisit]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't It throws an error for me - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried the script from the readme -
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ const compile = require("google-closure-compiler-js").compile; | |
|
||
let packagename, filename; | ||
|
||
const NUM_TEST_RUNS = 3; | ||
|
||
const script = new Command("benchmark.js") | ||
.option("-o, --offline", "Only install package if not present; package not removed after testing") | ||
.usage("[options] <package> [file]") | ||
|
@@ -35,7 +37,7 @@ if (!packagename) { | |
const pathToScripts = __dirname; | ||
|
||
const table = new Table({ | ||
head: ["", "raw", "raw win", "gzip", "gzip win", "parse time", "run"], | ||
head: ["", "raw", "raw win", "gzip", "gzip win", "parse time", "run time (average)"], | ||
chars: { | ||
top: "", | ||
"top-mid": "" , | ||
|
@@ -100,6 +102,7 @@ function checkFile() { | |
} | ||
|
||
function test(name, callback) { | ||
|
||
console.log("testing", name); | ||
|
||
const start = Date.now(); | ||
|
@@ -116,23 +119,54 @@ function test(name, callback) { | |
const parseEnd = Date.now(); | ||
const parseNow = parseEnd - parseStart; | ||
|
||
const runTimes = [run]; | ||
|
||
for (let i = 1; i < NUM_TEST_RUNS; i++) { | ||
const start = Date.now(); | ||
callback(code); | ||
runTimes.push(Date.now() - start); | ||
} | ||
|
||
const totalTime = runTimes.reduce((a, b) => a + b, 0); | ||
const average = parseInt(totalTime / runTimes.length, 10); | ||
|
||
results.push({ | ||
name: name, | ||
raw: result.length, | ||
gzip: gzipped.length, | ||
parse: parseNow, | ||
run: run, | ||
run: average, | ||
}); | ||
} | ||
|
||
function testFile() { | ||
code = fs.readFileSync(filename, "utf8"); | ||
gzippedCode = zlib.gzipSync(code); | ||
|
||
test("babili", function (code) { | ||
test("babili (best speed)", function (code) { | ||
return babel.transform(code, { | ||
sourceType: "script", | ||
presets: [require("../packages/babel-preset-babili")], | ||
presets: [ | ||
[require("../packages/babel-preset-babili"), { | ||
simplify: { | ||
multiPass: false | ||
} | ||
}] | ||
], | ||
comments: false, | ||
}).code; | ||
}); | ||
|
||
test("babili (best size)", function (code) { | ||
return babel.transform(code, { | ||
sourceType: "script", | ||
presets: [ | ||
[require("../packages/babel-preset-babili"), { | ||
simplify: { | ||
multiPass: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @boopathi this doesn't seem to show any difference in any of the files I'm testing... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is no multipass option implemented in simplify. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You implemented it here - in this commit - 827a835#diff-05684bffcab704dd5d3842adbf921357 and your latest changes don't seem to have this one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I'm an idiot, was thinking that we already added it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It still doesn't seem to work though. Am I missing something else? Should I change anything in options-manager? |
||
} | ||
}] | ||
], | ||
comments: false, | ||
}).code; | ||
}); | ||
|
@@ -161,9 +195,7 @@ function testFile() { | |
} | ||
|
||
function processResults() { | ||
results = results.sort(function (a, b) { | ||
return a.gzip > b.gzip; | ||
}); | ||
results = results.sort((a, b) => a.gzip > b.gzip); | ||
|
||
results.forEach(function (result, i) { | ||
let row = [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true by default which probably makes sense most of the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit too cryptic for my taste :) What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this (putting everything in one line and just one 2-level-deep option) it looks cryptic, actually using this is much clear sometimes, We could use default destructuring assignment when we have more options.