fix(benchpress): chrome - prevent trace buffer overflow
This commit is contained in:
parent
840cb3d69e
commit
2f442062d2
|
@ -24,6 +24,7 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
|||
static PROVIDERS = [ChromeDriverExtension];
|
||||
|
||||
private _majorChromeVersion: number;
|
||||
private _firstRun = true;
|
||||
|
||||
constructor(private _driver: WebDriverAdapter, @Inject(Options.USER_AGENT) userAgent: string) {
|
||||
super();
|
||||
|
@ -48,6 +49,12 @@ export class ChromeDriverExtension extends WebDriverExtension {
|
|||
gc() { return this._driver.executeScript('window.gc()'); }
|
||||
|
||||
timeBegin(name: string): Promise<any> {
|
||||
if (this._firstRun) {
|
||||
this._firstRun = false;
|
||||
// Before the first run, read out the existing performance logs
|
||||
// so that the chrome buffer does not fill up.
|
||||
this._driver.logs('performance');
|
||||
}
|
||||
return this._driver.executeScript(`console.time('${name}');`);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AsyncTestCompleter, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {AsyncTestCompleter, describe, expect, iit, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
|
||||
import {ChromeDriverExtension, Options, ReflectiveInjector, WebDriverAdapter, WebDriverExtension} from '../../index';
|
||||
import {TraceEventFactory} from '../trace_event_factory';
|
||||
|
@ -61,14 +61,29 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should mark the timeline via console.time()',
|
||||
it('should clear the perf logs and mark the timeline via console.time() on the first call',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
createExtension().timeBegin('someName').then((_) => {
|
||||
expect(log).toEqual([['executeScript', `console.time('someName');`]]);
|
||||
createExtension().timeBegin('someName').then(() => {
|
||||
expect(log).toEqual(
|
||||
[['logs', 'performance'], ['executeScript', `console.time('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should mark the timeline via console.time() on the second call',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const ext = createExtension();
|
||||
ext.timeBegin('someName')
|
||||
.then((_) => {
|
||||
log.splice(0, log.length);
|
||||
ext.timeBegin('someName');
|
||||
})
|
||||
.then(() => {
|
||||
expect(log).toEqual([['executeScript', `console.time('someName');`]]);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should mark the timeline via console.timeEnd()',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
createExtension().timeEnd('someName', null).then((_) => {
|
||||
|
|
Loading…
Reference in New Issue