fuwaneko / node-protobuf

Google Protocol Buffers wrapper for Node.js [UNMAINTAINED]
181 stars 42 forks source link

use named args, improves perf of parse and serialize by 5-8% #76

Closed InfinitiesLoop closed 8 years ago

InfinitiesLoop commented 8 years ago

Using named arguments on the protobuf.js wrapper instead of the arguments expression improves performance by a small but noticeable amount.

before: $ node test/perf/perfTest.js serializing and parsing a message 1,000,000 times... serialize: 8876ms parse: 8054ms

after: $ node test/perf/perfTest.js serializing and parsing a message 1,000,000 times... serialize: 8378ms # 5% faster parse: 7713ms # 4% faster

There's variance in the output, sometimes showing an 8% difference, but it's always faster. I noticed this when doing profiling of an application we are building, where protobuf parsing and serialization is where most of the work is. Our app needs to be very highly performant so this makes a big difference.

fuwaneko commented 8 years ago

Good point, various tests around the web seem to show that arguments object is always slower.