Skip to content

Instantly share code, notes, and snippets.

@A
Last active August 29, 2015 14:15
Show Gist options
  • Save A/5bb0b4ce1aca6798dd7f to your computer and use it in GitHub Desktop.
Save A/5bb0b4ce1aca6798dd7f to your computer and use it in GitHub Desktop.
Benchmark for Traceur and 6to5(Babel) es6 transpilers

I had benchmarked traceur and 6to5 on my project. One thing about the project:

~/work/ed master ~(˘▾˘~) ❯ find . -name "*.js" -type f -not -path "./node_modules/*" -not -path "*/public/*" | xargs cat | wc -l
  5651

node_modules had excluded from compilation, then exclude it from our wc -l.

Benchmark source

gulp.task('js:bench', function(done) {

  var time, total, i, count;
  total = 0;
  i = count = 10;

  function cb(err) {
    var time = timed.rounded() ;
    total += time;
    gutil.log('Built for ' + gutil.colors.cyan(time) + 'ms');
    i > 0
      ? next()
      : teardown();
  }

  function teardown() {
    var avg = total / count;
    gutil.log('Avg ' + gutil.colors.cyan(avg) + 'ms');
    done();
  }

  function next () {
    timed.reset();
    var b = browserify({ debug: true })
      // Traceur: 
      .add(require('es6ify').runtime)
      .transform(require('es6ify'))
      // 6to5
      // .add(require('regenerator').runtime.path)
      // .transform(require('6to5ify'))
      .transform(require('jadeify'))
      .external(dependencies)
      .add('./app/assets/javascripts/application.js')
      .add(engines)
      .bundle(cb)
    ;
    --i;
  }

  next();

});

Results

# 6to5
~/work/ed master ~(˘▾˘~) ❯ gulp js:bench

[04:08:50] Using gulpfile ~/work/ed/gulpfile.js
[04:08:50] Starting 'js:bench'...
[04:08:55] Built for 4893.386ms
[04:08:59] Built for 3931.519ms
[04:09:02] Built for 3800.076ms
[04:09:06] Built for 3737.031ms
[04:09:10] Built for 3776.933ms
[04:09:14] Built for 3701.922ms
[04:09:17] Built for 3732.177ms
[04:09:21] Built for 3707.868ms
[04:09:25] Built for 3778.302ms
[04:09:28] Built for 3698.17ms
[04:09:28] Avg 3875.7383999999997ms
[04:09:28] Finished 'js:bench' after 39 s
~/work/ed master ~(˘▾˘~) ❯

# Traceur
~/work/ed master ~(˘▾˘~) ❯ gulp js:bench

[04:15:19] Using gulpfile ~/work/ed/gulpfile.js
[04:15:19] Starting 'js:bench'...
[04:15:22] Built for 3406.532ms
[04:15:24] Built for 1420.165ms
[04:15:25] Built for 1347.992ms
[04:15:27] Built for 1339.779ms
[04:15:28] Built for 1376.281ms
[04:15:29] Built for 1387.337ms
[04:15:31] Built for 1365.312ms
[04:15:32] Built for 1355.812ms
[04:15:33] Built for 1351.436ms
[04:15:35] Built for 1380.212ms
[04:15:35] Avg 1573.0857999999998ms
[04:15:35] Finished 'js:bench' after 16 s
~/work/ed master ~(˘▾˘~) ❯
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment