MCPcopy Create free account
hub / github.com/angular/angular / PerflogMetric

Class PerflogMetric

packages/benchpress/src/metric/perflog_metric.ts:19–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 */
18@Injectable()
19export class PerflogMetric extends Metric {
20 static SET_TIMEOUT = new InjectionToken('PerflogMetric.setTimeout');
21 static IGNORE_NAVIGATION = new InjectionToken('PerflogMetric.ignoreNavigation');
22 static PROVIDERS = [
23 {
24 provide: PerflogMetric,
25 deps: [
26 WebDriverExtension,
27 PerflogMetric.SET_TIMEOUT,
28 Options.MICRO_METRICS,
29 Options.FORCE_GC,
30 Options.CAPTURE_FRAMES,
31 Options.RECEIVED_DATA,
32 Options.REQUEST_COUNT,
33 PerflogMetric.IGNORE_NAVIGATION,
34 ],
35 },
36 {
37 provide: PerflogMetric.SET_TIMEOUT,
38 useValue: (fn: Function, millis: number) => <any>setTimeout(fn, millis),
39 },
40 {provide: PerflogMetric.IGNORE_NAVIGATION, useValue: false},
41 ];
42
43 private _remainingEvents: PerfLogEvent[];
44 private _measureCount: number;
45 private _perfLogFeatures: PerfLogFeatures;
46
47 /**
48 * @param driverExtension
49 * @param setTimeout
50 * @param microMetrics Name and description of metrics provided via console.time / console.timeEnd
51 * @param ignoreNavigation If true, don't measure from navigationStart events. These events are
52 * usually triggered by a page load, but can also be triggered when adding iframes to the DOM.
53 **/
54 constructor(
55 private _driverExtension: WebDriverExtension,
56 @Inject(PerflogMetric.SET_TIMEOUT) private _setTimeout: Function,
57 @Inject(Options.MICRO_METRICS) private _microMetrics: {[key: string]: string},
58 @Inject(Options.FORCE_GC) private _forceGc: boolean,
59 @Inject(Options.CAPTURE_FRAMES) private _captureFrames: boolean,
60 @Inject(Options.RECEIVED_DATA) private _receivedData: boolean,
61 @Inject(Options.REQUEST_COUNT) private _requestCount: boolean,
62 @Inject(PerflogMetric.IGNORE_NAVIGATION) private _ignoreNavigation: boolean,
63 ) {
64 super();
65
66 this._remainingEvents = [];
67 this._measureCount = 0;
68 this._perfLogFeatures = _driverExtension.perfLogFeatures();
69 if (!this._perfLogFeatures.userTiming) {
70 // User timing is needed for navigationStart.
71 this._receivedData = false;
72 this._requestCount = false;
73 }
74 }
75
76 override describe(): {[key: string]: string} {

Callers

nothing calls this directly

Calls 1

setTimeoutFunction · 0.85

Tested by

no test coverage detected