humps x 3,050 ops/sec ±2.32% (76 runs sampled) camelcase-keys-recursive x 2,194 ops/sec ±3.16% (65 runs sampled) camelify-recursive x 1,491 ops/sec ±2.64% (74 runs sampled) camelize x 3,481 ops/sec ±2.27% (75 runs sampled) camelscore x 3,280 ops/sec ±2.66% (68 runs sampled) dolittlejs x 3,230 ops/sec ±2.13% (70 runs sampled) Fastest is camelize
Last active
January 13, 2016 22:36
-
-
Save jirutka/cc271b3cdd2b65bf6b32 to your computer and use it in GitHub Desktop.
Benchmark various JavaScript libs for recursive conversion of object keys from underscore_case to camelCase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"meta": { | |
"count": 2, | |
"offset": 0, | |
"limit": 20 | |
}, | |
"events": [ | |
{ | |
"id": 42, | |
"name": null, | |
"sequence_number": 12, | |
"starts_at": "2014-04-23T09:15:00.000+02:00", | |
"ends_at": "2014-04-23T10:45:00.000+02:00", | |
"deleted" : false, | |
"capacity": 24, | |
"event_type": "tutorial", | |
"parallel": "106", | |
"original_data": { | |
"starts_at": "2014-04-23T09:00:00.000+02:00", | |
"ends_at": "2014-04-23T10:30:00.000+02:00", | |
"room_id": "T9:111" | |
}, | |
"links": { | |
"room": "T9:350", | |
"course": "MI-RUB", | |
"teachers": [ | |
"skocdopet" | |
], | |
"students": [ | |
"szolatib", | |
"vomackar" | |
], | |
"applied_exceptions": [ 10, 15 ] | |
} | |
}, | |
{ | |
"id": 43, | |
"name": null, | |
"sequence_number": 12, | |
"starts_at": "2014-04-24T09:15:00.000+02:00", | |
"ends_at": "2014-04-24T10:45:00.000+02:00", | |
"deleted" : false, | |
"capacity": 196, | |
"event_type": "lecture", | |
"parallel": "1", | |
"original_data": {}, | |
"links": { | |
"room": "T9:155", | |
"course": "MI-W20", | |
"teachers": [ | |
"kuchajar", | |
"vitvatom" | |
], | |
"students": [ | |
"jirutjak" | |
] | |
} | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const Benchmark = require('benchmark') | |
const R = require('ramda') | |
const humps = require('humps') | |
const camelCaseRecursive = require('camelcase-keys-recursive') | |
const camelify = require('camelify-recursive') | |
const camelize = require('camelize') | |
const camelscore = require('camelscore') | |
const dolittle = require('dolittlejs') | |
const dataJson = require('./data.json') | |
const testData = () => JSON.parse(JSON.stringify(dataJson)) | |
const suite = new Benchmark.Suite | |
suite | |
.add('humps', () => { | |
humps.camelizeKeys(testData()) | |
}) | |
.add('camelcase-keys-recursive', () => { | |
camelCaseRecursive(testData()) | |
}) | |
.add('camelify-recursive', () => { | |
camelify(testData()) | |
}) | |
.add('camelize', () => { | |
camelize(testData()) | |
}) | |
.add('camelscore', () => { | |
camelscore.camelize(testData()) | |
}) | |
.add('dolittlejs', () => { | |
dolittle.to.camel(testData()) | |
}) | |
.on('cycle', event => { | |
console.log(String(event.target)) | |
}) | |
.on('complete', function() { | |
console.log('Fastest is ' + this.filter('fastest').map('name')) | |
}) | |
.on('error', event => { | |
console.log(event.target + 'ERROR!') | |
}) | |
.run({ 'async': true }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"benchmark": "^2.0.0", | |
"camelcase-keys-recursive": "^0.8.1", | |
"camelify-recursive": "^1.0.1", | |
"camelize": "^1.0.0", | |
"camelscore": "^0.1.2", | |
"change-case": "^2.3.0", | |
"dolittlejs": "^0.1.4", | |
"es6-shim": "^0.34.1", | |
"humps": "^1.0.0", | |
"microtime": "^2.0.0", | |
"ramda": "^0.19.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment