Skip to content

Instantly share code, notes, and snippets.

@airportyh
Last active August 29, 2015 13:56
Show Gist options
  • Save airportyh/9014213 to your computer and use it in GitHub Desktop.
Save airportyh/9014213 to your computer and use it in GitHub Desktop.
Benchmarks comparisons of Component with syntax-error feature applied.
var exec = require('child_process').exec
var async = require('async')
function run(command, times, callback){
var start = new Date().getTime()
async.eachSeries(Array(times), function(n, next){
exec(command, next)
}, function(err){
if (err) return callback(err)
var end = new Date().getTime()
var average = (end - start) / times
callback(null, average)
})
}
run('component build', 100, function(err, buildTime){
if (err) return console.error(err)
console.log('component build - average build time:', buildTime + 'ms')
run('mycomponent build', 100, function(err, buildTime){
if (err) return console.error(err)
console.log('mycomponent build - Average build time:', buildTime + 'ms')
})
})

Benchmark Results

One Component

$ ls components
component-select
$ node benchmark.js
component build - average build time: 446.23ms
mycomponent build - Average build time: 449.99ms

12 Components

$ ls components
component-classes     component-map
component-clone       component-props
component-diff        component-select
component-domify      component-to-function
component-emitter     component-type
component-indexof     component-uid
$ node benchmark.js 
component build - average build time: 462.44ms
mycomponent build - Average build time: 465.35ms

102 Components

$ ls components
component-array-parallel     component-query
component-assert             component-querystring
component-autoscale-canvas   component-raf
component-bind               component-range
component-calendar           component-reactive
component-caret              component-repeat
component-classes            component-schema
component-clickable          component-scroll-to
component-clone              component-select
component-collection         component-set
component-counter            component-spinner
component-create-element     component-stack
component-css                component-tip
component-delegate           component-title
component-dialog             component-to-function
component-diff               component-trim
component-dom                component-tween
component-domify             component-type
component-each               component-uid
component-ease               component-url
component-emitter            component-value
component-empty              component-within-document
component-enumerable         component-xmlhttprequest
component-event              enyo-domready
component-events             ianstormtaylor-is
component-format-parser      ianstormtaylor-is-empty
component-global             ianstormtaylor-map
component-grow               ianstormtaylor-to-camel-case
component-has-canvas         ianstormtaylor-to-no-case
component-has-cors           ianstormtaylor-to-space-case
component-history            jkroso-equals
component-humanize-keys      jkroso-type
component-image-size         juliangruber-isarray
component-in-groups-of       matthewp-keys
component-indexof            matthewp-text
component-inherit            redventures-reduce
component-inherits           segmentio-is-email
component-jpeg-size          segmentio-is-url
component-keyname            segmentio-on-body
component-map                stephenmathieson-normalize
component-matches-selector   timoxley-assert
component-menu               timoxley-dom-support
component-model              timoxley-offset
component-model-change       visionmedia-debug
component-model-http         visionmedia-superagent
component-model-validate     yields-carry
component-notification       yields-empty
component-overlay            yields-isarray
component-pillbox            yields-merge-attrs
component-png-size           yields-traverse
component-props              yields-uniq
$ node benchmark.js 
component build - average build time: 627.37ms
mycomponent build - Average build time: 638.07ms

Some Large Components

$ ls components
component-jquery
componentizr-angular.js
components-backbone
components-jquery
components-underscore
jashkenas-backbone
jashkenas-underscore
kelonye-ember
kelonye-ember-data
mbostock-d3
rreverser-knockout
sonicradish-backbone.marionette
timoxley-threejs
$ node benchmark.js 
component build - average build time: 664.75ms
mycomponent build - Average build time: 597.13ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment