@@ -2,10 +2,9 @@ import type * as ts from 'typescript';
2
2
import { Performance } from '../../profile/Performance' ;
3
3
4
4
interface TypeScriptPerformance {
5
- enable ( ) : void ;
6
- disable ( ) : void ;
7
- mark ( name : string ) : void ;
8
- measure ( name : string , startMark ?: string , endMark ?: string ) : void ;
5
+ enable ?( ) : void ;
6
+ disable ?( ) : void ;
7
+ forEachMeasure ?( callback : ( measureName : string , duration : number ) => void ) : void ;
9
8
}
10
9
11
10
function getTypeScriptPerformance ( typescript : typeof ts ) : TypeScriptPerformance | undefined {
@@ -20,27 +19,17 @@ function connectTypeScriptPerformance(
20
19
const typeScriptPerformance = getTypeScriptPerformance ( typescript ) ;
21
20
22
21
if ( typeScriptPerformance ) {
23
- const { mark, measure } = typeScriptPerformance ;
24
22
const { enable, disable } = performance ;
25
23
26
- typeScriptPerformance . mark = ( name ) => {
27
- mark ( name ) ;
28
- performance . mark ( name ) ;
29
- } ;
30
- typeScriptPerformance . measure = ( name , startMark , endMark ) => {
31
- measure ( name , startMark , endMark ) ;
32
- performance . measure ( name , startMark , endMark ) ;
33
- } ;
34
-
35
24
return {
36
25
...performance ,
37
26
enable ( ) {
38
27
enable ( ) ;
39
- typeScriptPerformance . enable ( ) ;
28
+ typeScriptPerformance . enable ?. ( ) ;
40
29
} ,
41
30
disable ( ) {
42
31
disable ( ) ;
43
- typeScriptPerformance . disable ( ) ;
32
+ typeScriptPerformance . disable ?. ( ) ;
44
33
} ,
45
34
} ;
46
35
} else {
0 commit comments