Socket
Book a DemoInstallSign in
Socket

write-buffer

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

write-buffer

Increase stream throughput by buffering small writes

unpublished
latest
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

write-buffer

Increases write throughput for small writes on node.js streams.

  • Buffers in memory for streams without writev support (like fs)
  • Uses cork when writev is supported (like tcp)

This is useful for doing stuff like writing access logs line by line to disk.


var fs = require('fs');
var writebuffer = require('write-buffer');

var stream = writebuffer(fs.createWriteStream('bla'), 1024);
for (var x = 0; x < 1000; x++) {
  stream.write('small');
}
stream.end();

Benchmark

I included a small benchmark script. It writes one million access log like strings in single writes

127.0.0.1 - - [24/Dec/2015:20:01:30 -0100] "GET /great-things HTTP/1.1" 200 3395

I got following results on my laptop.

FS


without buffer:

real  0m11.562s
user  0m5.224s
sys   0m7.403s

with buffer:

real  0m2.529s
user  0m1.472s
sys	  0m1.075s

TCP


without buffering:

real  0m1.201s
user  0m0.935s
sys	  0m0.273s

with buffer (cork):

real  0m1.046s
user  0m0.797s
sys	  0m0.265s

FAQs

Package last updated on 04 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts