Skip to content

Instantly share code, notes, and snippets.

@speg
Last active November 1, 2015 22:14
Show Gist options
  • Select an option

  • Save speg/f09f6af8d4959575e4c0 to your computer and use it in GitHub Desktop.

Select an option

Save speg/f09f6af8d4959575e4c0 to your computer and use it in GitHub Desktop.
fs = require('fs')
var bufferA = new Buffer(1e+9)
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, bufferA, 0, bufferB.length, function(err) { console.timeEnd('B')})
// expected output: B << A
// actual output on OS X node v5.0.0:
//A: 4443.194ms
//B: 4444.997ms
@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