2016-08-03 18:00:07 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2016-08-03 18:00:07 -04:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-08-26 19:34:08 -04:00
|
|
|
import {PerfLogEvent} from '../index';
|
2015-05-27 17:57:54 -04:00
|
|
|
|
|
|
|
export class TraceEventFactory {
|
2016-08-26 19:34:08 -04:00
|
|
|
constructor(private _cat: string, private _pid: string) {}
|
2015-05-27 17:57:54 -04:00
|
|
|
|
2016-08-26 19:34:08 -04:00
|
|
|
create(ph: any, name: string, time: number, args: any = null) {
|
2016-11-12 08:08:58 -05:00
|
|
|
const res:
|
2016-08-26 19:34:08 -04:00
|
|
|
PerfLogEvent = {'name': name, 'cat': this._cat, 'ph': ph, 'ts': time, 'pid': this._pid};
|
2017-03-02 12:37:01 -05:00
|
|
|
if (args != null) {
|
2015-05-27 17:57:54 -04:00
|
|
|
res['args'] = args;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2020-04-13 19:40:21 -04:00
|
|
|
markStart(name: string, time: number) {
|
|
|
|
return this.create('B', name, time);
|
|
|
|
}
|
2015-05-27 17:57:54 -04:00
|
|
|
|
2020-04-13 19:40:21 -04:00
|
|
|
markEnd(name: string, time: number) {
|
|
|
|
return this.create('E', name, time);
|
|
|
|
}
|
2015-05-27 17:57:54 -04:00
|
|
|
|
2020-04-13 19:40:21 -04:00
|
|
|
start(name: string, time: number, args: any = null) {
|
|
|
|
return this.create('B', name, time, args);
|
|
|
|
}
|
2015-05-27 17:57:54 -04:00
|
|
|
|
2020-04-13 19:40:21 -04:00
|
|
|
end(name: string, time: number, args: any = null) {
|
|
|
|
return this.create('E', name, time, args);
|
|
|
|
}
|
2015-05-27 17:57:54 -04:00
|
|
|
|
2016-08-26 19:34:08 -04:00
|
|
|
instant(name: string, time: number, args: any = null) {
|
2016-09-15 11:51:55 -04:00
|
|
|
return this.create('I', name, time, args);
|
2016-08-26 19:34:08 -04:00
|
|
|
}
|
2015-06-09 18:19:26 -04:00
|
|
|
|
2016-08-26 19:34:08 -04:00
|
|
|
complete(name: string, time: number, duration: number, args: any = null) {
|
2016-11-12 08:08:58 -05:00
|
|
|
const res = this.create('X', name, time, args);
|
2015-05-27 17:57:54 -04:00
|
|
|
res['dur'] = duration;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|