| 9 | import {PerfLogEvent} from '../index'; |
| 10 | |
| 11 | export class TraceEventFactory { |
| 12 | constructor( |
| 13 | private _cat: string, |
| 14 | private _pid: string, |
| 15 | ) {} |
| 16 | |
| 17 | create(ph: any, name: string, time: number, args: any = null) { |
| 18 | const res: PerfLogEvent = { |
| 19 | 'name': name, |
| 20 | 'cat': this._cat, |
| 21 | 'ph': ph, |
| 22 | 'ts': time, |
| 23 | 'pid': this._pid, |
| 24 | }; |
| 25 | if (args != null) { |
| 26 | res['args'] = args; |
| 27 | } |
| 28 | return res; |
| 29 | } |
| 30 | |
| 31 | markStart(name: string, time: number) { |
| 32 | return this.create('B', name, time); |
| 33 | } |
| 34 | |
| 35 | markEnd(name: string, time: number) { |
| 36 | return this.create('E', name, time); |
| 37 | } |
| 38 | |
| 39 | start(name: string, time: number, args: any = null) { |
| 40 | return this.create('B', name, time, args); |
| 41 | } |
| 42 | |
| 43 | end(name: string, time: number, args: any = null) { |
| 44 | return this.create('E', name, time, args); |
| 45 | } |
| 46 | |
| 47 | instant(name: string, time: number, args: any = null) { |
| 48 | return this.create('I', name, time, args); |
| 49 | } |
| 50 | |
| 51 | complete(name: string, time: number, duration: number, args: any = null) { |
| 52 | const res = this.create('X', name, time, args); |
| 53 | res['dur'] = duration; |
| 54 | return res; |
| 55 | } |
| 56 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…