@@ -769,14 +769,14 @@ namespace ts {
769
769
if ( ! reportWatchStatistics ) return ;
770
770
if ( d . code === Diagnostics . Found_0_errors_Watching_for_file_changes . code ||
771
771
d . code === Diagnostics . Found_1_error_Watching_for_file_changes . code ) {
772
- reportSolutionBuilderTimes ( sys , builder , buildHost ) ;
772
+ reportSolutionBuilderTimes ( sys , buildOptions , builder , buildHost ) ;
773
773
}
774
774
} ;
775
775
updateSolutionBuilderHost ( sys , cb , buildHost ) ;
776
776
enableSolutionPerformance ( sys , buildOptions ) ;
777
777
const builder = createSolutionBuilderWithWatch ( buildHost , projects , buildOptions , watchOptions ) ;
778
778
builder . build ( ) ;
779
- reportSolutionBuilderTimes ( sys , builder , buildHost ) ;
779
+ reportSolutionBuilderTimes ( sys , buildOptions , builder , buildHost ) ;
780
780
reportWatchStatistics = true ;
781
781
return builder ;
782
782
}
@@ -792,31 +792,33 @@ namespace ts {
792
792
enableSolutionPerformance ( sys , buildOptions ) ;
793
793
const builder = createSolutionBuilder ( buildHost , projects , buildOptions ) ;
794
794
const exitStatus = buildOptions . clean ? builder . clean ( ) : builder . build ( ) ;
795
- reportSolutionBuilderTimes ( sys , builder , buildHost ) ;
795
+ reportSolutionBuilderTimes ( sys , buildOptions , builder , buildHost ) ;
796
796
dumpTracingLegend ( ) ; // Will no-op if there hasn't been any tracing
797
797
return sys . exit ( exitStatus ) ;
798
798
}
799
799
800
800
function enableSolutionPerformance ( system : System , options : BuildOptions ) {
801
- if ( system === sys && ( options . diagnostics || options . extendedDiagnostics ) ) solutionPerformance . enable ( ) ;
801
+ if ( system === sys && options . solutionDiagnostics ) solutionPerformance . enable ( ) ;
802
802
}
803
803
804
- function reportSolutionBuilderTimes ( system : System , builder : SolutionBuilder < BuilderProgram > , buildHost : SolutionBuilderHost < BuilderProgram > ) {
805
- if ( system !== sys ) return ;
804
+ function reportSolutionBuilderTimes ( system : System , buildOptions : BuildOptions , builder : SolutionBuilder < BuilderProgram > , buildHost : SolutionBuilderHost < BuilderProgram > ) {
805
+ if ( system !== sys || ! buildOptions . solutionDiagnostics ) return ;
806
+
806
807
807
808
if ( solutionPerformance . isEnabled ( ) ) {
808
809
const solutionStatistics : Statistic [ ] = [ ] ;
809
- solutionPerformance . forEachMeasure ( ( name , duration ) => solutionStatistics . push ( { name : `${ name } time` , value : duration , type : StatisticType . time } ) ) ;
810
810
solutionStatistics . push (
811
- { name : "projectsBuilt" , value : solutionPerformance . getCount ( "projectsBuilt" ) , type : StatisticType . count } ,
812
- { name : "timestampUpdated" , value : solutionPerformance . getCount ( "timestampUpdated" ) , type : StatisticType . count } ,
813
- { name : "bundlesUpdated" , value : solutionPerformance . getCount ( "bundlesUpdated" ) , type : StatisticType . count } ,
814
- { name : "projects" , value : getBuildOrderFromAnyBuildOrder ( builder . getBuildOrder ( ) ) . length , type : StatisticType . count } ,
811
+ { name : "Projects" , value : getBuildOrderFromAnyBuildOrder ( builder . getBuildOrder ( ) ) . length , type : StatisticType . count } ,
815
812
) ;
813
+ solutionPerformance . forEachCount ( ( name , count ) => solutionStatistics . push ( { name, value : count , type : StatisticType . count } ) ) ;
814
+ solutionPerformance . forEachMeasure ( ( name , duration ) => solutionStatistics . push ( { name : `${ name } time` , value : duration , type : StatisticType . time } ) ) ;
816
815
buildHost . statistics = append ( buildHost . statistics , solutionStatistics ) ;
817
816
solutionPerformance . disable ( ) ;
818
817
solutionPerformance . enable ( ) ;
819
818
}
819
+ else {
820
+ sys . write ( Diagnostics . Performance_timings_for_diagnostics_or_extendedDiagnostics_or_solutionDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found . message + "\n" ) ;
821
+ }
820
822
821
823
if ( ! buildHost . statistics ) return ;
822
824
const statistics : Statistic [ ] = [ ] ;
@@ -990,16 +992,16 @@ namespace ts {
990
992
return createWatchProgram ( watchCompilerHost ) ;
991
993
}
992
994
993
- function canReportDiagnostics ( system : System , compilerOptions : CompilerOptions ) {
994
- return system === sys && ( compilerOptions . diagnostics || compilerOptions . extendedDiagnostics ) ;
995
+ function canGenerateStatistics ( system : System , compilerOptions : CompilerOptions ) {
996
+ return system === sys && ( compilerOptions . diagnostics || compilerOptions . extendedDiagnostics || compilerOptions . solutionDiagnostics ) ;
995
997
}
996
998
997
999
function canTrace ( system : System , compilerOptions : CompilerOptions ) {
998
1000
return system === sys && compilerOptions . generateTrace ;
999
1001
}
1000
1002
1001
1003
function enableStatisticsAndTracing ( system : System , compilerOptions : CompilerOptions , isBuildMode : boolean ) {
1002
- if ( canReportDiagnostics ( system , compilerOptions ) ) {
1004
+ if ( canGenerateStatistics ( system , compilerOptions ) ) {
1003
1005
performance . enable ( system ) ;
1004
1006
}
1005
1007
@@ -1022,15 +1024,15 @@ namespace ts {
1022
1024
}
1023
1025
1024
1026
let statistics : Statistic [ ] ;
1025
- if ( canReportDiagnostics ( sys , compilerOptions ) ) {
1027
+ if ( canGenerateStatistics ( sys , compilerOptions ) ) {
1026
1028
statistics = [ ] ;
1027
1029
const memoryUsed = sys . getMemoryUsage ? sys . getMemoryUsage ( ) : - 1 ;
1028
1030
if ( program ) {
1029
1031
reportCountStatistic ( "Files" , program . getSourceFiles ( ) . length ) ;
1030
1032
1031
1033
const lineCounts = countLines ( program ) ;
1032
1034
const nodeCounts = countNodes ( program ) ;
1033
- if ( compilerOptions . extendedDiagnostics ) {
1035
+ if ( compilerOptions . extendedDiagnostics || compilerOptions . solutionDiagnostics ) {
1034
1036
for ( const key of arrayFrom ( lineCounts . keys ( ) ) ) {
1035
1037
reportCountStatistic ( "Lines of " + key , lineCounts . get ( key ) ! ) ;
1036
1038
}
@@ -1058,7 +1060,7 @@ namespace ts {
1058
1060
const bindTime = isPerformanceEnabled ? performance . getDuration ( "Bind" ) : 0 ;
1059
1061
const checkTime = isPerformanceEnabled ? performance . getDuration ( "Check" ) : 0 ;
1060
1062
const emitTime = isPerformanceEnabled ? performance . getDuration ( "Emit" ) : 0 ;
1061
- if ( compilerOptions . extendedDiagnostics ) {
1063
+ if ( compilerOptions . extendedDiagnostics || compilerOptions . solutionDiagnostics ) {
1062
1064
if ( program ) {
1063
1065
const caches = program . getRelationCacheSizes ( ) ;
1064
1066
reportCountStatistic ( "Assignability cache size" , caches . assignable ) ;
@@ -1085,9 +1087,9 @@ namespace ts {
1085
1087
if ( isPerformanceEnabled ) {
1086
1088
reportTimeStatistic ( "Total time" , programTime + bindTime + checkTime + emitTime ) ;
1087
1089
}
1088
- reportAllStatistics ( sys , statistics ) ;
1090
+ if ( compilerOptions . diagnostics || compilerOptions . extendedDiagnostics ) reportAllStatistics ( sys , statistics ) ;
1089
1091
if ( ! isPerformanceEnabled ) {
1090
- 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" ) ;
1092
+ sys . write ( Diagnostics . Performance_timings_for_diagnostics_or_extendedDiagnostics_or_solutionDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found . message + "\n" ) ;
1091
1093
}
1092
1094
else {
1093
1095
performance . disable ( ) ;
0 commit comments