@@ -648,21 +648,22 @@ namespace ts {
648
648
reportStatisticalValue ( "Memory used" , Math . round ( memoryUsed / 1000 ) + "K" ) ;
649
649
}
650
650
651
- const programTime = performance . isEnabled ( ) ? performance . getDuration ( "Program" ) : 0 ;
652
- const bindTime = performance . isEnabled ( ) ? performance . getDuration ( "Bind" ) : 0 ;
653
- const checkTime = performance . isEnabled ( ) ? performance . getDuration ( "Check" ) : 0 ;
654
- const emitTime = performance . isEnabled ( ) ? performance . getDuration ( "Emit" ) : 0 ;
651
+ const isPerformanceEnabled = performance . isEnabled ( ) ;
652
+ const programTime = isPerformanceEnabled ? performance . getDuration ( "Program" ) : 0 ;
653
+ const bindTime = isPerformanceEnabled ? performance . getDuration ( "Bind" ) : 0 ;
654
+ const checkTime = isPerformanceEnabled ? performance . getDuration ( "Check" ) : 0 ;
655
+ const emitTime = isPerformanceEnabled ? performance . getDuration ( "Emit" ) : 0 ;
655
656
if ( compilerOptions . extendedDiagnostics ) {
656
657
const caches = program . getRelationCacheSizes ( ) ;
657
658
reportCountStatistic ( "Assignability cache size" , caches . assignable ) ;
658
659
reportCountStatistic ( "Identity cache size" , caches . identity ) ;
659
660
reportCountStatistic ( "Subtype cache size" , caches . subtype ) ;
660
661
reportCountStatistic ( "Strict subtype cache size" , caches . strictSubtype ) ;
661
- if ( performance . isEnabled ( ) ) {
662
+ if ( isPerformanceEnabled ) {
662
663
performance . forEachMeasure ( ( name , duration ) => reportTimeStatistic ( `${ name } time` , duration ) ) ;
663
664
}
664
665
}
665
- else if ( performance . isEnabled ( ) ) {
666
+ else if ( isPerformanceEnabled ) {
666
667
// Individual component times.
667
668
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
668
669
// I/O read time and processing time for triple-slash references and module imports, and the reported
@@ -674,11 +675,11 @@ namespace ts {
674
675
reportTimeStatistic ( "Check time" , checkTime ) ;
675
676
reportTimeStatistic ( "Emit time" , emitTime ) ;
676
677
}
677
- if ( performance . isEnabled ( ) ) {
678
+ if ( isPerformanceEnabled ) {
678
679
reportTimeStatistic ( "Total time" , programTime + bindTime + checkTime + emitTime ) ;
679
680
}
680
681
reportStatistics ( ) ;
681
- if ( ! performance . isEnabled ( ) ) {
682
+ if ( ! isPerformanceEnabled ) {
682
683
sys . write ( Diagnostics . Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found . message + "\n" ) ;
683
684
}
684
685
else {
0 commit comments