Skip to content

Instantly share code, notes, and snippets.

@sidorares
Forked from jordansissel/foo.js
Created September 28, 2011 01: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 sidorares/1246750 to your computer and use it in GitHub Desktop.
Save sidorares/1246750 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
@benatkin
Copy link

Might msgpack-js be faster?

There is also msgpack2, but it's wafsauce and no-issues-page-because-its-a-fork-sauce.

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