2015-03-13 06:10:11 -04:00
|
|
|
import {
|
|
|
|
afterEach,
|
|
|
|
AsyncTestCompleter,
|
|
|
|
beforeEach,
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
expect,
|
|
|
|
iit,
|
|
|
|
inject,
|
|
|
|
it,
|
|
|
|
xit,
|
|
|
|
} from 'angular2/test_lib';
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-27 13:37:02 -04:00
|
|
|
import { List, ListWrapper, StringMapWrapper } from 'angular2/src/facade/collection';
|
2015-02-11 13:13:49 -05:00
|
|
|
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
|
2015-03-06 20:34:27 -05:00
|
|
|
import { isPresent, isBlank } from 'angular2/src/facade/lang';
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-06 20:34:27 -05:00
|
|
|
import {
|
|
|
|
Metric, PerflogMetric, WebDriverExtension,
|
|
|
|
PerfLogFeatures,
|
|
|
|
bind, Injector, Options
|
|
|
|
} from 'benchpress/common';
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-02-18 17:39:52 -05:00
|
|
|
import { TraceEventFactory } from '../trace_event_factory';
|
|
|
|
|
2015-02-11 13:13:49 -05:00
|
|
|
export function main() {
|
|
|
|
var commandLog;
|
2015-02-18 17:39:52 -05:00
|
|
|
var eventFactory = new TraceEventFactory('timeline', 'pid0');
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-27 13:37:02 -04:00
|
|
|
function createMetric(perfLogs, microMetrics = null, perfLogFeatures = null) {
|
2015-02-11 13:13:49 -05:00
|
|
|
commandLog = [];
|
2015-03-06 20:34:27 -05:00
|
|
|
if (isBlank(perfLogFeatures)) {
|
|
|
|
perfLogFeatures = new PerfLogFeatures({render: true, gc: true});
|
|
|
|
}
|
2015-03-27 13:37:02 -04:00
|
|
|
if (isBlank(microMetrics)) {
|
|
|
|
microMetrics = StringMapWrapper.create();
|
|
|
|
}
|
2015-03-03 14:31:35 -05:00
|
|
|
var bindings = [
|
2015-03-06 20:34:27 -05:00
|
|
|
Options.DEFAULT_BINDINGS,
|
2015-02-11 13:13:49 -05:00
|
|
|
PerflogMetric.BINDINGS,
|
2015-03-27 13:37:02 -04:00
|
|
|
bind(Options.MICRO_METRICS).toValue(microMetrics),
|
2015-02-11 13:13:49 -05:00
|
|
|
bind(PerflogMetric.SET_TIMEOUT).toValue( (fn, millis) => {
|
|
|
|
ListWrapper.push(commandLog, ['setTimeout', millis]);
|
|
|
|
fn();
|
|
|
|
}),
|
2015-03-27 13:37:02 -04:00
|
|
|
bind(WebDriverExtension).toValue(new MockDriverExtension(perfLogs, commandLog, perfLogFeatures))
|
2015-03-03 14:31:35 -05:00
|
|
|
];
|
|
|
|
return new Injector(bindings).get(PerflogMetric);
|
2015-02-11 13:13:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
describe('perflog metric', () => {
|
|
|
|
|
2015-03-06 20:34:27 -05:00
|
|
|
it('should describe itself based on the perfLogFeatrues', () => {
|
2015-03-27 13:37:02 -04:00
|
|
|
expect(createMetric([[]], null, new PerfLogFeatures()).describe()).toEqual({
|
2015-03-06 20:34:27 -05:00
|
|
|
'scriptTime': 'script execution time in ms, including gc and render',
|
|
|
|
'pureScriptTime': 'script execution time in ms, without gc nor render'
|
|
|
|
});
|
|
|
|
|
2015-03-27 13:37:02 -04:00
|
|
|
expect(createMetric([[]], null, new PerfLogFeatures({
|
2015-03-06 20:34:27 -05:00
|
|
|
render: true,
|
|
|
|
gc: false
|
|
|
|
})).describe()).toEqual({
|
|
|
|
'scriptTime': 'script execution time in ms, including gc and render',
|
|
|
|
'pureScriptTime': 'script execution time in ms, without gc nor render',
|
|
|
|
'renderTime': 'render time in and ouside of script in ms',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(createMetric([[]]).describe()).toEqual({
|
|
|
|
'scriptTime': 'script execution time in ms, including gc and render',
|
|
|
|
'pureScriptTime': 'script execution time in ms, without gc nor render',
|
|
|
|
'renderTime': 'render time in and ouside of script in ms',
|
|
|
|
'gcTime': 'gc time in and ouside of script in ms',
|
|
|
|
'gcAmount': 'gc amount in kbytes',
|
|
|
|
'majorGcTime': 'time of major gcs in ms'
|
|
|
|
});
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
|
|
|
|
2015-03-27 13:37:02 -04:00
|
|
|
it('should describe itself based on micro metrics', () => {
|
|
|
|
var description = createMetric([[]], {
|
|
|
|
'myMicroMetric': 'someDesc'
|
|
|
|
}).describe();
|
|
|
|
expect(description['myMicroMetric']).toEqual('someDesc');
|
|
|
|
});
|
|
|
|
|
2015-02-11 13:13:49 -05:00
|
|
|
describe('beginMeasure', () => {
|
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should mark the timeline', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
var metric = createMetric([[]]);
|
|
|
|
metric.beginMeasure().then((_) => {
|
|
|
|
expect(commandLog).toEqual([['timeBegin', 'benchpress0']]);
|
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('endMeasure', () => {
|
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should mark and aggregate events in between the marks', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
var events = [
|
|
|
|
[
|
2015-02-18 17:39:52 -05:00
|
|
|
eventFactory.markStart('benchpress0', 0),
|
|
|
|
eventFactory.start('script', 4),
|
|
|
|
eventFactory.end('script', 6),
|
|
|
|
eventFactory.markEnd('benchpress0', 10)
|
2015-02-11 13:13:49 -05:00
|
|
|
]
|
|
|
|
];
|
|
|
|
var metric = createMetric(events);
|
|
|
|
metric.beginMeasure()
|
|
|
|
.then( (_) => metric.endMeasure(false) )
|
|
|
|
.then( (data) => {
|
|
|
|
expect(commandLog).toEqual([
|
|
|
|
['timeBegin', 'benchpress0'],
|
|
|
|
['timeEnd', 'benchpress0', null],
|
|
|
|
'readPerfLog'
|
|
|
|
]);
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(2);
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should restart timing', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
var events = [
|
|
|
|
[
|
2015-02-18 17:39:52 -05:00
|
|
|
eventFactory.markStart('benchpress0', 0),
|
|
|
|
eventFactory.markEnd('benchpress0', 1),
|
|
|
|
eventFactory.markStart('benchpress1', 2),
|
2015-02-11 13:13:49 -05:00
|
|
|
], [
|
2015-02-18 17:39:52 -05:00
|
|
|
eventFactory.markEnd('benchpress1', 3)
|
2015-02-11 13:13:49 -05:00
|
|
|
]
|
|
|
|
];
|
|
|
|
var metric = createMetric(events);
|
|
|
|
metric.beginMeasure()
|
|
|
|
.then( (_) => metric.endMeasure(true) )
|
|
|
|
.then( (_) => metric.endMeasure(true) )
|
|
|
|
.then( (_) => {
|
|
|
|
expect(commandLog).toEqual([
|
|
|
|
['timeBegin', 'benchpress0'],
|
|
|
|
['timeEnd', 'benchpress0', 'benchpress1'],
|
|
|
|
'readPerfLog',
|
|
|
|
['timeEnd', 'benchpress1', 'benchpress2'],
|
|
|
|
'readPerfLog'
|
|
|
|
]);
|
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should loop and aggregate until the end mark is present', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
var events = [
|
2015-02-18 17:39:52 -05:00
|
|
|
[ eventFactory.markStart('benchpress0', 0), eventFactory.start('script', 1) ],
|
|
|
|
[ eventFactory.end('script', 2) ],
|
|
|
|
[ eventFactory.start('script', 3), eventFactory.end('script', 5), eventFactory.markEnd('benchpress0', 10) ]
|
2015-02-11 13:13:49 -05:00
|
|
|
];
|
|
|
|
var metric = createMetric(events);
|
|
|
|
metric.beginMeasure()
|
|
|
|
.then( (_) => metric.endMeasure(false) )
|
|
|
|
.then( (data) => {
|
|
|
|
expect(commandLog).toEqual([
|
|
|
|
['timeBegin', 'benchpress0'],
|
|
|
|
['timeEnd', 'benchpress0', null],
|
|
|
|
'readPerfLog',
|
|
|
|
[ 'setTimeout', 100 ],
|
|
|
|
'readPerfLog',
|
|
|
|
[ 'setTimeout', 100 ],
|
|
|
|
'readPerfLog'
|
|
|
|
]);
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(3);
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should store events after the end mark for the next call', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
var events = [
|
2015-02-18 17:39:52 -05:00
|
|
|
[ eventFactory.markStart('benchpress0', 0), eventFactory.markEnd('benchpress0', 1), eventFactory.markStart('benchpress1', 1),
|
|
|
|
eventFactory.start('script', 1), eventFactory.end('script', 2) ],
|
|
|
|
[ eventFactory.start('script', 3), eventFactory.end('script', 5), eventFactory.markEnd('benchpress1', 6) ]
|
2015-02-11 13:13:49 -05:00
|
|
|
];
|
|
|
|
var metric = createMetric(events);
|
|
|
|
metric.beginMeasure()
|
|
|
|
.then( (_) => metric.endMeasure(true) )
|
|
|
|
.then( (data) => {
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(0);
|
2015-02-11 13:13:49 -05:00
|
|
|
return metric.endMeasure(true)
|
|
|
|
})
|
|
|
|
.then( (data) => {
|
|
|
|
expect(commandLog).toEqual([
|
|
|
|
['timeBegin', 'benchpress0'],
|
|
|
|
['timeEnd', 'benchpress0', 'benchpress1'],
|
|
|
|
'readPerfLog',
|
|
|
|
['timeEnd', 'benchpress1', 'benchpress2'],
|
|
|
|
'readPerfLog'
|
|
|
|
]);
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(3);
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('aggregation', () => {
|
|
|
|
|
2015-03-27 13:37:02 -04:00
|
|
|
function aggregate(events, microMetrics = null) {
|
2015-02-18 17:39:52 -05:00
|
|
|
ListWrapper.insert(events, 0, eventFactory.markStart('benchpress0', 0));
|
|
|
|
ListWrapper.push(events, eventFactory.markEnd('benchpress0', 10));
|
2015-03-27 13:37:02 -04:00
|
|
|
var metric = createMetric([events], microMetrics);
|
2015-02-11 13:13:49 -05:00
|
|
|
return metric
|
|
|
|
.beginMeasure().then( (_) => metric.endMeasure(false) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should report a single interval', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
aggregate([
|
2015-02-18 17:39:52 -05:00
|
|
|
eventFactory.start('script', 0),
|
|
|
|
eventFactory.end('script', 5)
|
2015-02-11 13:13:49 -05:00
|
|
|
]).then((data) => {
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(5);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should sum up multiple intervals', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
aggregate([
|
2015-02-18 17:39:52 -05:00
|
|
|
eventFactory.start('script', 0),
|
|
|
|
eventFactory.end('script', 5),
|
|
|
|
eventFactory.start('script', 10),
|
|
|
|
eventFactory.end('script', 17)
|
2015-02-11 13:13:49 -05:00
|
|
|
]).then((data) => {
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(12);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should ignore not started intervals', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
aggregate([
|
2015-02-18 17:39:52 -05:00
|
|
|
eventFactory.end('script', 10)
|
2015-02-11 13:13:49 -05:00
|
|
|
]).then((data) => {
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(0);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should ignore not ended intervals', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
aggregate([
|
2015-02-18 17:39:52 -05:00
|
|
|
eventFactory.start('script', 10)
|
2015-02-11 13:13:49 -05:00
|
|
|
]).then((data) => {
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(0);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should ignore events from different processed as the start mark', inject([AsyncTestCompleter], (async) => {
|
2015-02-18 17:39:52 -05:00
|
|
|
var otherProcessEventFactory = new TraceEventFactory('timeline', 'pid1');
|
|
|
|
var metric = createMetric([[
|
|
|
|
eventFactory.markStart('benchpress0', 0),
|
|
|
|
eventFactory.start('script', 0, null),
|
|
|
|
eventFactory.end('script', 5, null),
|
|
|
|
otherProcessEventFactory.start('script', 10, null),
|
|
|
|
otherProcessEventFactory.end('script', 17, null),
|
|
|
|
eventFactory.markEnd('benchpress0', 20)
|
|
|
|
]]);
|
|
|
|
metric.beginMeasure()
|
|
|
|
.then( (_) => metric.endMeasure(false) )
|
|
|
|
.then((data) => {
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(5);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-18 17:39:52 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-18 17:39:52 -05:00
|
|
|
|
2015-03-06 20:34:27 -05:00
|
|
|
it('should support scriptTime metric', inject([AsyncTestCompleter], (async) => {
|
|
|
|
aggregate([
|
|
|
|
eventFactory.start('script', 0),
|
|
|
|
eventFactory.end('script', 5)
|
|
|
|
]).then((data) => {
|
|
|
|
expect(data['scriptTime']).toBe(5);
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should support renderTime metric', inject([AsyncTestCompleter], (async) => {
|
|
|
|
aggregate([
|
|
|
|
eventFactory.start('render', 0),
|
|
|
|
eventFactory.end('render', 5)
|
|
|
|
]).then((data) => {
|
|
|
|
expect(data['renderTime']).toBe(5);
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-13 06:10:11 -04:00
|
|
|
it('should support gcTime/gcAmount metric', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
aggregate([
|
2015-02-18 17:39:52 -05:00
|
|
|
eventFactory.start('gc', 0, {'usedHeapSize': 2500}),
|
|
|
|
eventFactory.end('gc', 5, {'usedHeapSize': 1000})
|
2015-02-11 13:13:49 -05:00
|
|
|
]).then((data) => {
|
2015-03-04 12:59:18 -05:00
|
|
|
expect(data['gcTime']).toBe(5);
|
2015-02-18 17:39:52 -05:00
|
|
|
expect(data['gcAmount']).toBe(1.5);
|
2015-03-04 12:59:18 -05:00
|
|
|
expect(data['majorGcTime']).toBe(0);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-03-04 12:59:18 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-03-04 12:59:18 -05:00
|
|
|
|
2015-03-06 20:34:27 -05:00
|
|
|
it('should support majorGcTime metric', inject([AsyncTestCompleter], (async) => {
|
2015-03-04 12:59:18 -05:00
|
|
|
aggregate([
|
|
|
|
eventFactory.start('gc', 0, {'usedHeapSize': 2500}),
|
|
|
|
eventFactory.end('gc', 5, {'usedHeapSize': 1000, 'majorGc': true})
|
|
|
|
]).then((data) => {
|
|
|
|
expect(data['gcTime']).toBe(5);
|
|
|
|
expect(data['majorGcTime']).toBe(5);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-06 20:34:27 -05:00
|
|
|
it('should support pureScriptTime = scriptTime-gcTime-renderTime', inject([AsyncTestCompleter], (async) => {
|
2015-02-11 13:13:49 -05:00
|
|
|
aggregate([
|
2015-02-18 17:39:52 -05:00
|
|
|
eventFactory.start('script', 0),
|
|
|
|
eventFactory.start('gc', 1, {'usedHeapSize': 1000}),
|
|
|
|
eventFactory.end('gc', 4, {'usedHeapSize': 0}),
|
2015-03-06 20:34:27 -05:00
|
|
|
eventFactory.start('render', 4),
|
|
|
|
eventFactory.end('render', 5),
|
|
|
|
eventFactory.end('script', 6)
|
2015-02-11 13:13:49 -05:00
|
|
|
]).then((data) => {
|
2015-03-06 20:34:27 -05:00
|
|
|
expect(data['scriptTime']).toBe(6);
|
|
|
|
expect(data['pureScriptTime']).toBe(2);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-02-11 13:13:49 -05:00
|
|
|
|
2015-03-27 13:37:02 -04:00
|
|
|
describe('microMetrics', () => {
|
2015-03-03 14:31:35 -05:00
|
|
|
|
2015-03-27 13:37:02 -04:00
|
|
|
it('should report micro metrics', inject([AsyncTestCompleter], (async) => {
|
2015-03-03 14:31:35 -05:00
|
|
|
aggregate([
|
2015-03-27 13:37:02 -04:00
|
|
|
eventFactory.markStart('mm1', 0),
|
|
|
|
eventFactory.markEnd('mm1', 5),
|
|
|
|
], {'mm1': 'micro metric 1'}).then((data) => {
|
|
|
|
expect(data['mm1']).toBe(5.0);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-03-03 14:31:35 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-03-03 14:31:35 -05:00
|
|
|
|
2015-03-27 13:37:02 -04:00
|
|
|
it('should ignore micro metrics that were not specified', inject([AsyncTestCompleter], (async) => {
|
2015-03-03 14:31:35 -05:00
|
|
|
aggregate([
|
2015-03-27 13:37:02 -04:00
|
|
|
eventFactory.markStart('mm1', 0),
|
|
|
|
eventFactory.markEnd('mm1', 5),
|
|
|
|
]).then((data) => {
|
|
|
|
expect(data['mm1']).toBeFalsy();
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should report micro metric averages', inject([AsyncTestCompleter], (async) => {
|
|
|
|
aggregate([
|
|
|
|
eventFactory.markStart('mm1*20', 0),
|
|
|
|
eventFactory.markEnd('mm1*20', 5),
|
|
|
|
], {'mm1': 'micro metric 1'}).then((data) => {
|
|
|
|
expect(data['mm1']).toBe(5/20);
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-03-03 14:31:35 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-03-03 14:31:35 -05:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-02-11 13:13:49 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
class MockDriverExtension extends WebDriverExtension {
|
|
|
|
_perfLogs:List;
|
|
|
|
_commandLog:List;
|
2015-03-06 20:34:27 -05:00
|
|
|
_perfLogFeatures:PerfLogFeatures;
|
|
|
|
constructor(perfLogs, commandLog, perfLogFeatures) {
|
2015-02-11 13:13:49 -05:00
|
|
|
super();
|
|
|
|
this._perfLogs = perfLogs;
|
|
|
|
this._commandLog = commandLog;
|
2015-03-06 20:34:27 -05:00
|
|
|
this._perfLogFeatures = perfLogFeatures;
|
2015-02-11 13:13:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
timeBegin(name):Promise {
|
|
|
|
ListWrapper.push(this._commandLog, ['timeBegin', name]);
|
|
|
|
return PromiseWrapper.resolve(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
timeEnd(name, restartName):Promise {
|
|
|
|
ListWrapper.push(this._commandLog, ['timeEnd', name, restartName]);
|
|
|
|
return PromiseWrapper.resolve(null);
|
|
|
|
}
|
|
|
|
|
2015-03-06 20:34:27 -05:00
|
|
|
perfLogFeatures():PerfLogFeatures {
|
|
|
|
return this._perfLogFeatures;
|
|
|
|
}
|
|
|
|
|
2015-02-11 13:13:49 -05:00
|
|
|
readPerfLog():Promise {
|
|
|
|
ListWrapper.push(this._commandLog, 'readPerfLog');
|
|
|
|
if (this._perfLogs.length > 0) {
|
|
|
|
var next = this._perfLogs[0];
|
|
|
|
ListWrapper.removeAt(this._perfLogs, 0);
|
|
|
|
return PromiseWrapper.resolve(next);
|
|
|
|
} else {
|
|
|
|
return PromiseWrapper.resolve([]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|