@@ -122,17 +122,25 @@ var getBenchmarkFiles = function (benchmark, spec) {
122122} ;
123123
124124var config = exports . config = {
125- // Disable waiting for Angular as we don't have an integration layer yet...
126- // TODO(tbosch): Implement a proper debugging API for Ng2.0, remove this here
127- // and the sleeps in all tests.
128125 onPrepare : function ( ) {
129- browser . ignoreSynchronization = true ;
130- var _get = browser . get ;
131- var sleepInterval = process . env . TRAVIS || process . env . JENKINS_URL ? 7000 : 3000 ;
132- browser . get = function ( ) {
133- var result = _get . apply ( this , arguments ) ;
134- browser . sleep ( sleepInterval ) ;
135- return result ;
126+ patchProtractorWait ( browser ) ;
127+ // During benchmarking, we need to open a new browser
128+ // for every benchmark, otherwise the numbers can get skewed
129+ // from other benchmarks (e.g. Chrome keeps JIT caches, ...)
130+ if ( argv [ 'benchmark' ] ) {
131+ var originalBrowser = browser ;
132+ var _tmpBrowser ;
133+ beforeEach ( function ( ) {
134+ global . browser = originalBrowser . forkNewDriverInstance ( ) ;
135+ patchProtractorWait ( global . browser ) ;
136+ global . element = global . browser . element ;
137+ global . $ = global . browser . $ ;
138+ global . $$ = global . browser . $$ ;
139+ } ) ;
140+ afterEach ( function ( ) {
141+ global . browser . quit ( ) ;
142+ global . browser = originalBrowser ;
143+ } ) ;
136144 }
137145 } ,
138146
@@ -166,6 +174,20 @@ var config = exports.config = {
166174 }
167175} ;
168176
177+ // Disable waiting for Angular as we don't have an integration layer yet...
178+ // TODO(tbosch): Implement a proper debugging API for Ng2.0, remove this here
179+ // and the sleeps in all tests.
180+ function patchProtractorWait ( browser ) {
181+ browser . ignoreSynchronization = true ;
182+ var _get = browser . get ;
183+ var sleepInterval = process . env . TRAVIS || process . env . JENKINS_URL ? 7000 : 3000 ;
184+ browser . get = function ( ) {
185+ var result = _get . apply ( this , arguments ) ;
186+ browser . sleep ( sleepInterval ) ;
187+ return result ;
188+ }
189+ }
190+
169191exports . createBenchpressRunner = function ( options ) {
170192 var nodeUuid = require ( 'node-uuid' ) ;
171193 var benchpress = require ( './dist/js/cjs/benchpress/benchpress' ) ;
0 commit comments