-
Notifications
You must be signed in to change notification settings - Fork 4
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
Not fast enough #3
Comments
For some reason, the node version speeds up if you provide a long string |
yocontra
pushed a commit
to yocontra/yes
that referenced
this issue
Jun 13, 2017
adds buffering and removes cruft to increase perf
#!/usr/bin/env node
var msg = process.argv.length > 2 ? process.argv[2] : 'y';
var Readable = require('stream').Readable
var rs = new Readable;
var c = 0;
var size = Buffer.byteLength(msg, "utf8")
msg = msg + '\r\n'
rs._read = function () {
c++;
rs.push(msg);
};
rs.pipe(process.stdout)
process.on('exit', function () {
console.error('\n_read() called ' + c + ' times');
});
process.stdout.on('error', process.exit); |
#!/usr/bin/env node
var msg = (process.argv.length > 2 ? process.argv[2] : 'y') + '\r\n';
var repeatedMsg = msg.repeat(Math.max(1, Math.floor(8192 / Buffer.byteLength(msg, 'utf8'))));
var buf = Buffer.from(repeatedMsg, 'utf8');
var pump = function() {
process.stdout.write(buf, null, pump);
};
pump(); seems to reach ~1.85 GiB/s with a 9000 byte payload, where |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected
Pure JavaScript
yes
is the finestyes
in all the land.Actual
Gnu coreutils yes is approximately 142 times faster than Pure JavaScript
yes
😭The text was updated successfully, but these errors were encountered: