Skip to content

Instantly share code, notes, and snippets.

@jordansissel
Created September 28, 2011 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jordansissel/1246663 to your computer and use it in GitHub Desktop.
Save jordansissel/1246663 to your computer and use it in GitHub Desktop.
nodejs msgpack is slowsauce.
msgpack = require("msgpack-0.4");
msgpack.pack(JSON.parse(require("fs").readFileSync("../var/inputs.json")))
require "rubygems"
require "msgpack"
require "json"
puts MessagePack.pack(JSON.parse(File.read("../var/inputs.json")))

node is node 0.4.8 with msgpack-0.4 (since 'msgpack is abandoned and fails in node 0.4.x. ruby is ruby 1.8.7

Majority of time spent is in msgpack.pack for nodejs. Input file "inputs.json" is 4.7MB of json:

% du -sh ../var/inputs.json
4.7M    ../var/inputs.json

% time node foo.js 
node foo.js  16.63s user 0.10s system 98% cpu 17.069 total

% time ruby foo.rb
ruby foo.rb  0.29s user 0.05s system 98% cpu 0.341 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment