Skip to content

Instantly share code, notes, and snippets.

@speg
Last active November 1, 2015 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save speg/f09f6af8d4959575e4c0 to your computer and use it in GitHub Desktop.
Save speg/f09f6af8d4959575e4c0 to your computer and use it in GitHub Desktop.
fs = require('fs')
var bufferA = new Buffer(1e+8)
bufferA.fill(0)
var bufferB = new Buffer(1e+0)
bufferB.fill(0)
var fileA = fs.openSync('fileA', 'w')
var fileB = fs.openSync('fileB', 'w')
console.time('A')
fs.write(fileA, bufferA, 0, bufferA.length, function(err) { console.timeEnd('A')})
console.time('B')
fs.write(fileB, bufferB, 0, bufferB.length, function(err) { console.timeEnd('B')})
// expected output: B << A
// actual output on OS X node v5.0.0:
// A: 314.564ms
// B: 315.864ms
// Output on Linux:
// B: 4ms <-- yes!
// A: 306ms
@hguillermo
Copy link

I got this in Mac OS X and node 5.

A: 115.469ms
B: 116.775ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment