/node-benchmarks

Benchmarking various operations in Node.JS

Primary LanguageJavaScript

Node.JS Benchmarks

NPM

Javascript is a non-opinionated language and allows you to do an operation in many ways. This repository tries to find which approach is faster in a range of different systems.

Installation

$ npm install -g benchmarks

Usage

$ node-benchmarks --help
Usage: node-benchmarks [options]
Options:
    -h, --help         output usage information
    -V, --version      output the version number
    -p, --path [path]  Path to output the results to
    -d, --dryrun       Run the benchmark but dont generate files

$ node-benchmarks -p myresults/
[1/21]  type_check
[2/21]  send_buf
[3/21]  manip_recv_buf
[4/21]  duplicate
[5/21]  object_loop
[6/21]  bluebird_vs_q
[7/21]  array_filter
[8/21]  conditional
[9/21]  array_prepend
[10/21] buf_write
[11/21] delete
[12/21] inc_int
[13/21] function_call
[14/21] proto_vs_literal
[15/21] delete_last_item
[16/21] array_map
[17/21] string_search
[18/21] buf_read
[19/21] round_num
[20/21] array_loop
[21/21] str_to_int

Your benchmark results will be appended to the result set.

$ node-benchmarks --dryrun
typeof x 22,545,486 ops/sec ±11.66% (30 runs sampled)
constructor check x 18,023,021 ops/sec ±9.23% (27 runs sampled)
Fastest is typeof

[1/22]  type_check
buffer x 10,889 ops/sec ±15.81% (28 runs sampled)
string+ x 53,569 ops/sec ±21.72% (27 runs sampled)
Fastest is string+

[2/22]  manip_recv_buf
filterDuplicates x 17,466 ops/sec ±7.64% (26 runs sampled)
eliminateDuplicates x 19,910 ops/sec ±7.11% (28 runs sampled)
Fastest is eliminateDuplicates

When --dryrun is used, no files are generated and the results are shown on the console.

Results

You can find the result sets here. I recommend you fork and send a pull requests to add your results to this list.

Contribute

// first fork this repo
$ git clone git@github.com:YOURUSERNAME/node-benchmarks.git
$ cd node-benchmarks
$ npm install
$ bin/node-benchmarks
$ git add .
$ git commit -m 'added new results'
$ git push origin master
// last send pull request

History

Can be seen here.