node package manager


Track the duration of parts of your gulp tasks


Track the duration of parts of your gulp tasks.

Useful, for example, when running a periodic watch-like task but not using or gulp's task dependency system.

Creates a new pass-through duration stream. When this stream is closed, it will log the amount of time since its creation to your terminal.

Optionally, you can pass a name to use when logging – defaults to gulp-duration.

Resets the stream's "start time" to the current time. Use this in your pipeline to only track the duration after a certain event.

Here's a simple example:

var duration = require('gulp-duration')
var uglify = require('gulp-uglify')
var concat = require('gulp-concat')
var gulp = reuqire('gulp')
gulp.task('interval', function() {
  setInterval(function() {
      .pipe(duration('rebuilding files'))
  }, 5000)

And something a little less trivial:

var source = require('vinyl-source-stream')
var uglify = require('gulp-uglify')
var watchify = require('watchify')
var gulp = require('gulp')
gulp.task('example', function() {
  var bundler = watchify({
    entries: ['./index.js']
  }).on('update', rebundle)
  return rebundle()
  function rebundle() {
    var uglifyTimer = duration('uglify time')
    var bundleTimer = duration('bundle time')
    return bundler.bundle()
      // start just before uglify recieves its first file 
      .once('data', uglifyTimer.start)

MIT. See for details.