From eb6385e143707a41afed419a7ad719b60bc71e67 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Wed, 4 Mar 2015 10:27:26 -0800 Subject: [PATCH] fix(build): open new window for every benchmark --- protractor-shared.js | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/protractor-shared.js b/protractor-shared.js index ead58a61df..489ed46352 100644 --- a/protractor-shared.js +++ b/protractor-shared.js @@ -122,17 +122,25 @@ var getBenchmarkFiles = function (benchmark, spec) { }; var config = exports.config = { - // Disable waiting for Angular as we don't have an integration layer yet... - // TODO(tbosch): Implement a proper debugging API for Ng2.0, remove this here - // and the sleeps in all tests. onPrepare: function() { - browser.ignoreSynchronization = true; - var _get = browser.get; - var sleepInterval = process.env.TRAVIS || process.env.JENKINS_URL ? 7000 : 3000; - browser.get = function() { - var result = _get.apply(this, arguments); - browser.sleep(sleepInterval); - return result; + patchProtractorWait(browser); + // During benchmarking, we need to open a new browser + // for every benchmark, otherwise the numbers can get skewed + // from other benchmarks (e.g. Chrome keeps JIT caches, ...) + if (argv['benchmark']) { + var originalBrowser = browser; + var _tmpBrowser; + beforeEach(function() { + global.browser = originalBrowser.forkNewDriverInstance(); + patchProtractorWait(global.browser); + global.element = global.browser.element; + global.$ = global.browser.$; + global.$$ = global.browser.$$; + }); + afterEach(function() { + global.browser.quit(); + global.browser = originalBrowser; + }); } }, @@ -166,6 +174,20 @@ var config = exports.config = { } }; +// Disable waiting for Angular as we don't have an integration layer yet... +// TODO(tbosch): Implement a proper debugging API for Ng2.0, remove this here +// and the sleeps in all tests. +function patchProtractorWait(browser) { + browser.ignoreSynchronization = true; + var _get = browser.get; + var sleepInterval = process.env.TRAVIS || process.env.JENKINS_URL ? 7000 : 3000; + browser.get = function() { + var result = _get.apply(this, arguments); + browser.sleep(sleepInterval); + return result; + } +} + exports.createBenchpressRunner = function(options) { var nodeUuid = require('node-uuid'); var benchpress = require('./dist/js/cjs/benchpress/benchpress');