tunnckoCore / blankr

:heart: tasks, todos, ideas, streaks, WIP, etc
https://i.am.charlike.online
4 stars 1 forks source link

Ock vs. Gulp - Round 1 #13

Open tunnckoCore opened 9 years ago

tunnckoCore commented 9 years ago

Scenario (copy/paste with template populate)

  1. src globs
  2. compile templates with simple data
  3. write to dest

    Main points

    • Ock x2-x3 faster, continuous tests in recent months
    • no matter how much files and folders read and compile (11 or 25k)
    • Ock built on top of readdirp and minimatch only.
    • Ock have stream, callback and promise api
    • also see this, notice times
      gulpfile.js
var gulp = require('gulp');
var through2 = require('through2');
var jed = require('gulp-j140');
var countFiles = 1, dateformat=require('dateformat'), ms = require('pretty-ms')

gulp.task('default', function () {
  return gulp.src(['./try-catch/*.*', './try-catch/.*'])
    .pipe(through2.obj(function (file, _, next) {
      if (countFiles === 1) {
        start = Date.now()
      }
      countFiles++
      console.log(dateformat(new Date, '[HH:MM:ss]') + ' ' + file.relative)
      this.push(file)
      next()
    }))
    .pipe(jed({name: 'Charlike'}))
    .pipe(gulp.dest('build-gulp'))
    .pipe(through2.obj(function (obj, _, next) {
      //console.log('create:',path.join('build',obj.file.relative))
      next();
    },
    // finish
    function (finish) {
      console.log(dateformat(new Date, '[HH:MM:ss]') + ' Found ' + countFiles + ' files')
      finish()
    }))
});

Results

charlike@node ~/dev $
charlike@node ~/dev $
charlike@node ~/dev $ node ockfile.js
[10:32:36] Using ockfile ~/dev/ockfile.js
[10:32:36] Starting `default`...
[10:32:36] .editorconfig
[10:32:36] .gitattributes
[10:32:36] .gitignore
[10:32:36] .jshintrc
[10:32:36] .travis.yml
[10:32:36] history.md
[10:32:36] license.md
[10:32:36] package.json
[10:32:36] readme.md
[10:32:36] test.js
[10:32:36] Found 11 files
[10:32:36] Finished `default` after 37ms
charlike@node ~/dev $
charlike@node ~/dev $ gulp
[10:32:39] Using gulpfile ~/dev/gulpfile.js
[10:32:39] Starting 'default'...
[10:32:39] history.md
[10:32:39] license.md
[10:32:39] package.json
[10:32:39] readme.md
[10:32:39] test.js
[10:32:39] .editorconfig
[10:32:39] .gitattributes
[10:32:39] .gitignore
[10:32:39] .jshintrc
[10:32:39] .travis.yml
[10:32:39] Found 11 files
[10:32:39] Finished 'default' after 109 ms
charlike@node ~/dev $
charlike@node ~/dev $ rm -rf build-*
charlike@node ~/dev $
tunnckoCore commented 9 years ago

more playing

charlike@node ~/dev $
charlike@node ~/dev $
charlike@node ~/dev $ node ockfile.js
[11:24:16] Using ockfile ~/dev/ockfile.js
[11:24:16] Starting `default`...
[11:24:28] Started at `11:24:16`
[11:24:28] Found 2969 files
[11:24:28] Finished `default` after 11.6s
charlike@node ~/dev $
charlike@node ~/dev $ rm -rf build-*
charlike@node ~/dev $ gulp
[11:25:43] Using gulpfile ~/dev/gulpfile.js
[11:25:43] Starting `default`...
[11:26:06] Started at `11:25:43`
[11:26:06] Found 2969 files
[11:26:06] Finished `default` after 23.4s
charlike@node ~/dev $
charlike@node ~/dev $ echo '// notice not deleting build-gulp!!!'
// notice not deleting build-gulp!!!
charlike@node ~/dev $
charlike@node ~/dev $ node ockfile.js
[11:26:37] Using ockfile ~/dev/ockfile.js
[11:26:37] Starting `default`...
[11:26:53] Started at `11:26:37`
[11:26:53] Found 4261 files
[11:26:53] Finished `default` after 16.5s
charlike@node ~/dev $
charlike@node ~/dev $
charlike@node ~/dev $
tunnckoCore commented 9 years ago

@jonschlinkert very much work in progress, but... yeah. Just readdirp with through2, and minimatch.

For that I saying that newest approach based on gulp / glob-stream in Assemble and Verb is slow.

tunnckoCore commented 9 years ago

PS: yea, Ock isn't commited (open-sourced), yet.