2016-08-03 18:00:07 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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-03 15:32:26 -04:00
|
|
|
import {isPresent} from '@angular/facade/src/lang';
|
2015-05-27 17:57:54 -04:00
|
|
|
|
|
|
|
export class TraceEventFactory {
|
|
|
|
private _cat: string;
|
|
|
|
private _pid;
|
|
|
|
|
|
|
|
constructor(cat, pid) {
|
|
|
|
this._cat = cat;
|
|
|
|
this._pid = pid;
|
|
|
|
}
|
|
|
|
|
|
|
|
create(ph, name, time, args = null) {
|
|
|
|
var res = {'name': name, 'cat': this._cat, 'ph': ph, 'ts': time, 'pid': this._pid};
|
|
|
|
if (isPresent(args)) {
|
|
|
|
res['args'] = args;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
markStart(name, time) { return this.create('b', name, time); }
|
|
|
|
|
|
|
|
markEnd(name, time) { return this.create('e', name, time); }
|
|
|
|
|
|
|
|
start(name, time, args = null) { return this.create('B', name, time, args); }
|
|
|
|
|
|
|
|
end(name, time, args = null) { return this.create('E', name, time, args); }
|
|
|
|
|
2015-06-09 18:19:26 -04:00
|
|
|
instant(name, time, args = null) { return this.create('i', name, time, args); }
|
|
|
|
|
2015-05-27 17:57:54 -04:00
|
|
|
complete(name, time, duration, args = null) {
|
|
|
|
var res = this.create('X', name, time, args);
|
|
|
|
res['dur'] = duration;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|