-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
buffer: removed unused variable conf from buffer-base64-decode & buffer-base64-encode #10175
Conversation
I'm not sure it's worth removing. Benchmarks like this probably should have defined parameters containing defaults of at least the currently used values. |
@mscdex Does this mean you would endorse (or at least not object to) a change from this: var bench = common.createBenchmark(main, {});
function main(conf) {
var N = 64 * 1024 * 1024;
var b = Buffer.allocUnsafe(N);
var s = '';
var i;
for (i = 0; i < 256; ++i) s += String.fromCharCode(i);
for (i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii');
bench.start();
for (i = 0; i < 32; ++i) b.toString('base64');
bench.end(64);
} ...to something more like this?: var bench = common.createBenchmark(main, {
N: [64 * 1024 * 1024],
});
function main(conf) {
var N = +conf.N;
var b = Buffer.allocUnsafe(N);
var s = '';
var i;
for (i = 0; i < 256; ++i) s += String.fromCharCode(i);
for (i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii');
bench.start();
for (i = 0; i < 32; ++i) b.toString('base64');
bench.end(64);
} |
@Trott Pretty much, although the iteration count might be configurable as well like with most other benchmarks. |
@troy0820 I think it would be better, yes. Just make sure to also add a parameter for the number of iterations (usually lowercase |
@mscdex That would be the number of iterations in the loop between |
@Trott Correct. I don't know why 64 was being passed in the encode benchmark, it should be the loop count which is 32. |
@troy0820 You up for making those changes as described above and trying to ascertain what the similar changes might be for the other file? (I'd guess just the iterations and nothing else in that file, but take a look and judge for yourself.) |
@Trott Yeah I can make those changes. It sounds like it's the above snippet along with the only change being the 32 in the |
@troy0820 You'll want to add an |
bb1f3b1
to
a2af2c7
Compare
@@ -1,16 +1,20 @@ | |||
'use strict'; | |||
var common = require('../common.js'); | |||
|
|||
var bench = common.createBenchmark(main, {}); | |||
const bench = common.createBenchmark(main, { | |||
N: [64 * 1024 * 1024], |
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.
We might want to give this a better name to avoid confusion. I think other benchmarks use names like len
, which I would be fine with.
|
||
function main(conf) { | ||
const n = conf.n; |
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 should be +conf.n
.
|
||
function main(conf) { | ||
var N = 64 * 1024 * 1024; | ||
var n = conf.n; | ||
var N = conf.N; |
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.
Similarly for these, the values should be prefixed with +
to ensure they are numbers.
@@ -3,15 +3,15 @@ var common = require('../common.js'); | |||
|
|||
const bench = common.createBenchmark(main, { | |||
N: [64 * 1024 * 1024], |
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.
Sorry, I meant this parameter should be called len
. n
should stay the same.
ac30244
to
3edffd5
Compare
for (i = 0; i < 32; ++i) b.toString('base64'); | ||
bench.end(64); | ||
for (i = 0; i < n; ++i) b.toString('base64'); | ||
bench.end(n); |
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.
Is the change from 64
to 32
in the bench.end(n)
here intentional?
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.
Nevermind... just spotted the other comment about it :-)
Ping @mscdex |
var b = Buffer.allocUnsafe(N); | ||
var s = ''; | ||
var i; | ||
const n = +conf.len; |
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 should be const n = +conf.n;
var s = ''; | ||
var i; | ||
const n = +conf.len; | ||
const N = +conf.N; |
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 should be const len = +conf.len;
var i; | ||
const n = +conf.len; | ||
const N = +conf.N; | ||
const b = Buffer.allocUnsafe(N); |
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 should be const b = Buffer.allocUnsafe(len);
const N = +conf.N; | ||
const b = Buffer.allocUnsafe(N); | ||
let s = ''; | ||
let i; | ||
for (i = 0; i < 256; ++i) s += String.fromCharCode(i); | ||
for (i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii'); |
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.
N
here should be len
3edffd5
to
ad77d92
Compare
Rebased master and made changes @mscdex |
LGTM |
Only relevant CI job for this is the linter, so here it is: |
…on in buffer-base64-encode & buffer-base64-decode.js
ad77d92
to
8f096db
Compare
Hmmm, the linter failed, but that might have been because it needed a rebase, which I just did. Let's try again... |
Linter is ✅ |
8f096db
to
08cdc9c
Compare
Add configuration object createBenchmark object for buffer size & iteration in buffer-base64-encode & buffer-base64-decode.js. PR-URL: nodejs#10175 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
Add configuration object createBenchmark object for buffer size & iteration in buffer-base64-encode & buffer-base64-decode.js. PR-URL: #10175 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
Add configuration object createBenchmark object for buffer size & iteration in buffer-base64-encode & buffer-base64-decode.js. PR-URL: #10175 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
Add configuration object createBenchmark object for buffer size & iteration in buffer-base64-encode & buffer-base64-decode.js. PR-URL: #10175 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
Add configuration object createBenchmark object for buffer size & iteration in buffer-base64-encode & buffer-base64-decode.js. PR-URL: #10175 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
Add configuration object createBenchmark object for buffer size & iteration in buffer-base64-encode & buffer-base64-decode.js. PR-URL: #10175 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
Removed unused variable
conf
from buffer-base64-decode.js and buffer-based64-encode.jsChecklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
Buffer
Description of change
Deleted variable that wasn't used which was
conf