Skip to content

Instantly share code, notes, and snippets.

@luk-
Created March 23, 2013 20:52
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 luk-/5229312 to your computer and use it in GitHub Desktop.
Save luk-/5229312 to your computer and use it in GitHub Desktop.
var fs = require('fs')
var _ = require('lodash')
var Benchmark = require('benchmark').Benchmark
var suite = new Benchmark.Suite
var filter = Benchmark.filter
suite.add('readFileSync#toString', function () {
var file = fs.readFileSync('./changelog').toString()
})
suite.add('readFileSync#utf8', function () {
var file = fs.readFileSync('./changelog', 'utf8')
})
.on('complete', function () {
var fastest = filter(this, 'fastest')
var slowest = filter(this, 'slowest')
console.log('fastest: ' + fastest)
console.log('slowest: ' + slowest)
})
.run({'async': false})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment