質問

With Grunt, when you are registering tasks, how much slower is it to use tasks you already registered, maybe with several subtasks of their own, versus using tasks straight from initConfig, or even writing the functions by hand in the registration? Here's an example:

How much slower would specifying grunt minify from the command line be here:

grunt.registerTask('minify', ['preprocessed', 'nonprocessed']);
gruntregisterTask('preprocessed', ['sass:convert', 'haml:convert']);
grunt.registerTask('nonprocessed', ['uglify', 'cssmin', 'htmlmin', 'phpmin']);

than if you created the minify task like this:

grunt.registerTask('minify', ['sass:convert', 'haml:convert', 'uglify', 'cssmin', 'htmlmin', 'phpmin']);

I have to believe there is at least some slowdown, as Grunt has to go through more steps to "see" the tasks at each level of abstraction, but I just want to know if it's something to worry about only with thousands of modules, tens of sub-tasks per task, etc. or if it'll affect smaller projects as well.

役に立ちましたか?

解決

You can test this yourself by using time-grunt.

// Gruntfile.js
module.exports = function (grunt) {
    // require it at the top and pass in the grunt instance
    require('time-grunt')(grunt);

    grunt.initConfig();
}

Personally I've never noticed any speed decrease by specifying more aliases rather than less, and if there is slowdown it'll be in milliseconds. It'd be interesting to see a full test suite though.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top