1
|
/**
|
2
|
* @license
|
3
|
* Copyright Google Inc. All Rights Reserved.
|
4
|
*
|
5
|
* Use of this source code is governed by an MIT-style license that can be
|
6
|
* found in the LICENSE file at https://angular.io/license
|
7
|
*/
|
8
|
import { WtfScopeFn } from './wtf_impl';
|
9
|
export { WtfScopeFn } from './wtf_impl';
|
10
|
/**
|
11
|
* True if WTF is enabled.
|
12
|
*/
|
13
|
export declare const wtfEnabled: boolean;
|
14
|
/**
|
15
|
* Create trace scope.
|
16
|
*
|
17
|
* Scopes must be strictly nested and are analogous to stack frames, but
|
18
|
* do not have to follow the stack frames. Instead it is recommended that they follow logical
|
19
|
* nesting. You may want to use
|
20
|
* [Event
|
21
|
* Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
|
22
|
* as they are defined in WTF.
|
23
|
*
|
24
|
* Used to mark scope entry. The return value is used to leave the scope.
|
25
|
*
|
26
|
* var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
|
27
|
*
|
28
|
* someMethod() {
|
29
|
* var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
|
30
|
* // DO SOME WORK HERE
|
31
|
* return wtfLeave(s, 123); // Return value 123
|
32
|
* }
|
33
|
*
|
34
|
* Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
|
35
|
* negatively impact the performance of your application. For this reason we recommend that
|
36
|
* you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
|
37
|
* so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
|
38
|
* exception, will produce incorrect trace, but presence of exception signifies logic error which
|
39
|
* needs to be fixed before the app should be profiled. Add try-finally only when you expect that
|
40
|
* an exception is expected during normal execution while profiling.
|
41
|
*
|
42
|
* @experimental
|
43
|
*/
|
44
|
export declare const wtfCreateScope: (signature: string, flags?: any) => WtfScopeFn;
|
45
|
/**
|
46
|
* Used to mark end of Scope.
|
47
|
*
|
48
|
* - `scope` to end.
|
49
|
* - `returnValue` (optional) to be passed to the WTF.
|
50
|
*
|
51
|
* Returns the `returnValue for easy chaining.
|
52
|
* @experimental
|
53
|
*/
|
54
|
export declare const wtfLeave: <T>(scope: any, returnValue?: T) => T;
|
55
|
/**
|
56
|
* Used to mark Async start. Async are similar to scope but they don't have to be strictly nested.
|
57
|
* The return value is used in the call to [endAsync]. Async ranges only work if WTF has been
|
58
|
* enabled.
|
59
|
*
|
60
|
* someMethod() {
|
61
|
* var s = wtfStartTimeRange('HTTP:GET', 'some.url');
|
62
|
* var future = new Future.delay(5).then((_) {
|
63
|
* wtfEndTimeRange(s);
|
64
|
* });
|
65
|
* }
|
66
|
* @experimental
|
67
|
*/
|
68
|
export declare const wtfStartTimeRange: (rangeType: string, action: string) => any;
|
69
|
/**
|
70
|
* Ends a async time range operation.
|
71
|
* [range] is the return value from [wtfStartTimeRange] Async ranges only work if WTF has been
|
72
|
* enabled.
|
73
|
* @experimental
|
74
|
*/
|
75
|
export declare const wtfEndTimeRange: (range: any) => void;
|