Skip to content

Instantly share code, notes, and snippets.

@joliss
Last active January 4, 2016 06:49
Show Gist options
  • Save joliss/8584850 to your computer and use it in GitHub Desktop.
Save joliss/8584850 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
(
echo -n -e '\xc3\x96'
dd if=/dev/zero bs=1048576 count=100
) > big-file
echo
node -e "
var fs = require('fs')
console.time('Node read')
for (var i = 0; i < 1; i++) {
fs.readFileSync('big-file')
}
console.timeEnd('Node read')
console.time('Node read and decode')
for (i = 0; i < 1; i++) {
fs.readFileSync('big-file', { encoding: 'utf8' })
}
console.timeEnd('Node read and decode')
"
echo -n 'Ruby read and decode: '
ruby -e "
start = Time.now
File.read('big-file', encoding: 'utf-8')
puts '%ims' % ((Time.now - start) * 1000)
"
rm big-file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment