4 ms·
> node -e "process.stdout.write('@'.repeat(128 * 1024)); process.stdout.write(''); process.exit(0);" | wc -c That's missing the part where it waits for the las
by ecedeno 2y ago
> node -e "process.stdout.write('@'.repeat(128 * 1024)); process.stdout.write(''); process.exit(0);" | wc -c
That's missing the part where it waits for the last write to flush before exiting.
- 3np 2y agoYou might think that would be it? $ node -e "process.stdout.write('@'.repeat(128 * 1024)); process.stdout.write(''); setTimeout(()=>{ process.exit(0); }, 0);" | wc -c 131072 Sure. But not so fast! You're still just racing and have no guarantees. Increase the pressure and it snaps back: $ node -e "process.stdout.write('@'.repeat(1280 * 1024)); process.stdout.write(''); setTimeout(()=>{ process.exit(0); }, 0);" | wc -c 65536 Meanwhile: $ node -e "const { Stream } = require('stream'); s = process.stdout; s.write('@'.repeat(1280 * 1024)); Stream.finished(s, () => { process.exit(0); })" | wc -c 1310720
- deleted 2y ago[deleted]
- Thorrez 2y agoYou're not passing anything into the 2nd parameter of stdout.write()