@@ -769,14 +769,14 @@ namespace ts {
769769 if ( ! reportWatchStatistics ) return ;
770770 if ( d . code === Diagnostics . Found_0_errors_Watching_for_file_changes . code ||
771771 d . code === Diagnostics . Found_1_error_Watching_for_file_changes . code ) {
772- reportSolutionBuilderTimes ( sys , builder , buildHost ) ;
772+ reportSolutionBuilderTimes ( sys , buildOptions , builder , buildHost ) ;
773773 }
774774 } ;
775775 updateSolutionBuilderHost ( sys , cb , buildHost ) ;
776776 enableSolutionPerformance ( sys , buildOptions ) ;
777777 const builder = createSolutionBuilderWithWatch ( buildHost , projects , buildOptions , watchOptions ) ;
778778 builder . build ( ) ;
779- reportSolutionBuilderTimes ( sys , builder , buildHost ) ;
779+ reportSolutionBuilderTimes ( sys , buildOptions , builder , buildHost ) ;
780780 reportWatchStatistics = true ;
781781 return builder ;
782782 }
@@ -792,31 +792,33 @@ namespace ts {
792792 enableSolutionPerformance ( sys , buildOptions ) ;
793793 const builder = createSolutionBuilder ( buildHost , projects , buildOptions ) ;
794794 const exitStatus = buildOptions . clean ? builder . clean ( ) : builder . build ( ) ;
795- reportSolutionBuilderTimes ( sys , builder , buildHost ) ;
795+ reportSolutionBuilderTimes ( sys , buildOptions , builder , buildHost ) ;
796796 dumpTracingLegend ( ) ; // Will no-op if there hasn't been any tracing
797797 return sys . exit ( exitStatus ) ;
798798 }
799799
800800 function enableSolutionPerformance ( system : System , options : BuildOptions ) {
801- if ( system === sys && ( options . diagnostics || options . extendedDiagnostics ) ) solutionPerformance . enable ( ) ;
801+ if ( system === sys && options . solutionDiagnostics ) solutionPerformance . enable ( ) ;
802802 }
803803
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+
806807
807808 if ( solutionPerformance . isEnabled ( ) ) {
808809 const solutionStatistics : Statistic [ ] = [ ] ;
809- solutionPerformance . forEachMeasure ( ( name , duration ) => solutionStatistics . push ( { name : `${ name } time` , value : duration , type : StatisticType . time } ) ) ;
810810 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 } ,
815812 ) ;
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 } ) ) ;
816815 buildHost . statistics = append ( buildHost . statistics , solutionStatistics ) ;
817816 solutionPerformance . disable ( ) ;
818817 solutionPerformance . enable ( ) ;
819818 }
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+ }
820822
821823 if ( ! buildHost . statistics ) return ;
822824 const statistics : Statistic [ ] = [ ] ;
@@ -990,16 +992,16 @@ namespace ts {
990992 return createWatchProgram ( watchCompilerHost ) ;
991993 }
992994
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 ) ;
995997 }
996998
997999 function canTrace ( system : System , compilerOptions : CompilerOptions ) {
9981000 return system === sys && compilerOptions . generateTrace ;
9991001 }
10001002
10011003 function enableStatisticsAndTracing ( system : System , compilerOptions : CompilerOptions , isBuildMode : boolean ) {
1002- if ( canReportDiagnostics ( system , compilerOptions ) ) {
1004+ if ( canGenerateStatistics ( system , compilerOptions ) ) {
10031005 performance . enable ( system ) ;
10041006 }
10051007
@@ -1022,15 +1024,15 @@ namespace ts {
10221024 }
10231025
10241026 let statistics : Statistic [ ] ;
1025- if ( canReportDiagnostics ( sys , compilerOptions ) ) {
1027+ if ( canGenerateStatistics ( sys , compilerOptions ) ) {
10261028 statistics = [ ] ;
10271029 const memoryUsed = sys . getMemoryUsage ? sys . getMemoryUsage ( ) : - 1 ;
10281030 if ( program ) {
10291031 reportCountStatistic ( "Files" , program . getSourceFiles ( ) . length ) ;
10301032
10311033 const lineCounts = countLines ( program ) ;
10321034 const nodeCounts = countNodes ( program ) ;
1033- if ( compilerOptions . extendedDiagnostics ) {
1035+ if ( compilerOptions . extendedDiagnostics || compilerOptions . solutionDiagnostics ) {
10341036 for ( const key of arrayFrom ( lineCounts . keys ( ) ) ) {
10351037 reportCountStatistic ( "Lines of " + key , lineCounts . get ( key ) ! ) ;
10361038 }
@@ -1058,7 +1060,7 @@ namespace ts {
10581060 const bindTime = isPerformanceEnabled ? performance . getDuration ( "Bind" ) : 0 ;
10591061 const checkTime = isPerformanceEnabled ? performance . getDuration ( "Check" ) : 0 ;
10601062 const emitTime = isPerformanceEnabled ? performance . getDuration ( "Emit" ) : 0 ;
1061- if ( compilerOptions . extendedDiagnostics ) {
1063+ if ( compilerOptions . extendedDiagnostics || compilerOptions . solutionDiagnostics ) {
10621064 if ( program ) {
10631065 const caches = program . getRelationCacheSizes ( ) ;
10641066 reportCountStatistic ( "Assignability cache size" , caches . assignable ) ;
@@ -1085,9 +1087,9 @@ namespace ts {
10851087 if ( isPerformanceEnabled ) {
10861088 reportTimeStatistic ( "Total time" , programTime + bindTime + checkTime + emitTime ) ;
10871089 }
1088- reportAllStatistics ( sys , statistics ) ;
1090+ if ( compilerOptions . diagnostics || compilerOptions . extendedDiagnostics ) reportAllStatistics ( sys , statistics ) ;
10891091 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" ) ;
10911093 }
10921094 else {
10931095 performance . disable ( ) ;
0 commit comments