Gulp task runs much faster without 'return' statement - why is that?

mikhail-t

Gulp task formed like this (without return) runs much faster:

gulp.task('less', function () {
  gulp.src('./less/**/*.less')
   .pipe(less())
   .pipe(gulp.dest('./destination'));
});

than the same one with return:

gulp.task('less', function () {
  return gulp.src('./less/**/*.less')
   .pipe(less())
   .pipe(gulp.dest('./destination'));
});

So, my question is what does Gulp task is supposed to return? Why is it so much faster without return, while it still generates expected files?

mikhail-t

After some investigation I found that when return is used on Gulp task it's not actually slower at all, it just returns correct time it took to finish the task.

It only felt faster since without return statement it essentially returned result as completed almost instantly, so the task time looked like few ms, but the actual process continued on the background and completed silently.

So, it's safe to say that it's prefferable to use return on all your tasks that have gulp.src().

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Why is ifstream::read much faster than using iterators?

分類Dev

Why pcre regex is much faster than c++11 regex

分類Dev

Why are floating point operations much faster with a warmup phase?

分類Dev

why dose the first loop always runs faster than the second one?

分類Dev

Redirection in laravel without return statement

分類Dev

Why is implicit casting is much faster than explicit in JS? Is implicit casting a good practice?

分類Dev

Why is populating a Vec via replacing defaults so much faster than populating something with preset capacity?

分類Dev

Performance - why is a prime-generating algorithm with range much faster than using prime list?

分類Dev

Why is my DSL connection so slow, when my neighbor's is much faster?

分類Dev

Why are Scala for loops so much faster than while loops for processing a sequence of distinct objects?

分類Dev

why code after the return statement is reachable in javascript

分類Dev

Why does the return statement not return any text, whilst print does?

分類Dev

Gulp watch, wait for task

分類Dev

Why does this Task return early? Have I done something wrong?

分類Dev

Why does this Task return early? Have I done something wrong?

分類Dev

Mysql subquery much faster than join

分類Dev

MongoDB $or query against itself much faster

分類Dev

Make algorithm faster that runs over multiple lists

分類Dev

Android 5.0 std::clock() runs faster

分類Dev

Why execution stops after return statement in c++?

分類Dev

Which of the printf() will be faster and why?

分類Dev

Why if-else if-else (within a loop) in method gives "return statement missing" while all if-else branches have a return statement?

分類Dev

Why C++ doesn't default construct return value when return statement is not specified?

分類Dev

How to create a task that runs in the background in Android

分類Dev

How much faster is C++ than C#?

分類Dev

How much faster is C++ than C#?

分類Dev

How much faster is C++ than C#?

分類Dev

How much faster is NCHW compared to NHWC in TensorFlow/cuDNN?

分類Dev

When switching between sound devices, playback gets much faster

Related 関連記事

  1. 1

    Why is ifstream::read much faster than using iterators?

  2. 2

    Why pcre regex is much faster than c++11 regex

  3. 3

    Why are floating point operations much faster with a warmup phase?

  4. 4

    why dose the first loop always runs faster than the second one?

  5. 5

    Redirection in laravel without return statement

  6. 6

    Why is implicit casting is much faster than explicit in JS? Is implicit casting a good practice?

  7. 7

    Why is populating a Vec via replacing defaults so much faster than populating something with preset capacity?

  8. 8

    Performance - why is a prime-generating algorithm with range much faster than using prime list?

  9. 9

    Why is my DSL connection so slow, when my neighbor's is much faster?

  10. 10

    Why are Scala for loops so much faster than while loops for processing a sequence of distinct objects?

  11. 11

    why code after the return statement is reachable in javascript

  12. 12

    Why does the return statement not return any text, whilst print does?

  13. 13

    Gulp watch, wait for task

  14. 14

    Why does this Task return early? Have I done something wrong?

  15. 15

    Why does this Task return early? Have I done something wrong?

  16. 16

    Mysql subquery much faster than join

  17. 17

    MongoDB $or query against itself much faster

  18. 18

    Make algorithm faster that runs over multiple lists

  19. 19

    Android 5.0 std::clock() runs faster

  20. 20

    Why execution stops after return statement in c++?

  21. 21

    Which of the printf() will be faster and why?

  22. 22

    Why if-else if-else (within a loop) in method gives "return statement missing" while all if-else branches have a return statement?

  23. 23

    Why C++ doesn't default construct return value when return statement is not specified?

  24. 24

    How to create a task that runs in the background in Android

  25. 25

    How much faster is C++ than C#?

  26. 26

    How much faster is C++ than C#?

  27. 27

    How much faster is C++ than C#?

  28. 28

    How much faster is NCHW compared to NHWC in TensorFlow/cuDNN?

  29. 29

    When switching between sound devices, playback gets much faster

ホットタグ

アーカイブ