Timing is everything
Some plugins I use (such as the jasmine plugin) output how long they take to run (to the console). This is a pretty neat feature, but very few plugins do it.
Obviously you don’t want to fork each plugin (there are 100s) and implement a timer in each, so I had another idea.
I threw grunt-timer.js together in a couple of hours. It uses the documented hooker.(un)hook to (as closely as possible) determine the elapsed execution time for each task as they are run by Grunt.
Shouldn’t this be part of Grunt?
I think so, possibly as an option that can be configured. It would have been a lot easier to implement too, it’s a little hacky the way I’ve done it using hooks and the time isn’t 100% accurate.
Hopefully people will find this useful and the equivalent will find its way into the core.
How do I use it?
Add the grunt-timer reference to the very top of your Gruntfile.js:
Add the timer init call at the top of the module.exports function of your Gruntfile.js::
I haven’t spent too much time on this so far, and there are a couple of issues that exist:
- The last task duration is output after the “Done, without errors”.
- Tasks that wrap multi-tasks are currently output (shouldn’t be, or if they are, should be a summary of all the multitasks).
Feel free to fork and pull request on the git repo.