From 5dd3f030af13af9239e2e65a9febc642ff42e54f Mon Sep 17 00:00:00 2001 From: VanDalkvist Date: Mon, 4 Apr 2016 17:44:47 +0300 Subject: [PATCH] added separated gulp tasks for performance scenarios (for dev speed); --- gulp/performance-tests.js | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/gulp/performance-tests.js b/gulp/performance-tests.js index 1c5a4f8..6300a43 100644 --- a/gulp/performance-tests.js +++ b/gulp/performance-tests.js @@ -4,6 +4,8 @@ var gulpIf = require('gulp-if'); var benchmark = require('gulp-benchmark'); var _ = require('lodash'); var isAppveyor = require('./util/is-appveyor.js'); +var fs = require('fs'); +var path = require('path'); function minimalRatio() { return 2 / 3; @@ -38,12 +40,7 @@ function getSlowTestSuites(file) { gulp.task('performance-tests', ['all-tests-with-no-performance'], function () { return gulp .src('./performance-tests/tests/**/*.js', {read: false}) - .pipe(benchmark({ - reporters: [ - benchmark.reporters.etalon('knockout'), - benchmark.reporters.json() - ] - })) + .pipe(benchmarkSetup()) .pipe(gulp.dest('./out/reports')); /* TODO: results seem to vary on different machines (90x times faster, 50x times slover). Ignore them for now. @@ -58,3 +55,26 @@ gulp.task('performance-tests', ['all-tests-with-no-performance'], function () { }, true))); */ }); + +var perfTestsPath = './performance-tests/tests'; +var files = fs.readdirSync(perfTestsPath); +files.forEach(function (file) { + if (!fs.lstatSync(path.join(perfTestsPath, file)).isDirectory()) return; + + gulp.task('performance-scenario-' + file, [], function () { + return gulp + .src(path.join(perfTestsPath, file, '/**/*.js'), {read: false}) + .pipe(benchmarkSetup()) + .pipe(gulp.dest('./out/reports')); + }); + +}); + +function benchmarkSetup() { + return benchmark({ + reporters: [ + benchmark.reporters.etalon('knockout'), + benchmark.reporters.json() + ] + }); +} \ No newline at end of file