Skip to content

Commit 672e3a2

Browse files
committed
WIP
1 parent 9f336c9 commit 672e3a2

File tree

5 files changed

+552
-10
lines changed

5 files changed

+552
-10
lines changed

src/Compiler/Driver/fsc.fs

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,13 @@ let getParallelReferenceResolutionFromEnvironment () =
458458
Some ParallelReferenceResolution.Off
459459
| false, _ -> None)
460460

461+
type Timer(name : string) =
462+
let sw = Stopwatch.StartNew()
463+
do printfn $"{name} - start"
464+
member this.Dispose() = printfn $"{name} - end - {sw.Elapsed.TotalSeconds}s"
465+
interface IDisposable with
466+
member this.Dispose() = this.Dispose()
467+
461468
/// First phase of compilation.
462469
/// - Set up console encoding and code page settings
463470
/// - Process command line, flags and collect filenames
@@ -477,7 +484,8 @@ let main1
477484
diagnosticsLoggerProvider: IDiagnosticsLoggerProvider,
478485
disposables: DisposablesTracker
479486
) =
480-
487+
use _ = new Timer("main1")
488+
use init = new Timer("main1.init")
481489
// See Bug 735819
482490
let lcidFromCodePage =
483491
if
@@ -553,7 +561,9 @@ let main1
553561
// Display the banner text, if necessary
554562
if not bannerAlreadyPrinted then
555563
Console.Write(GetBannerText tcConfigB)
556-
564+
565+
init.Dispose()
566+
557567
// Create tcGlobals and frameworkTcImports
558568
let outfile, pdbfile, assemblyName =
559569
try
@@ -595,6 +605,7 @@ let main1
595605
let sysRes, otherRes, knownUnresolved =
596606
TcAssemblyResolutions.SplitNonFoundationalResolutions(tcConfig)
597607

608+
let basic = new Timer("import basic assemblies")
598609
// Import basic assemblies
599610
let tcGlobals, frameworkTcImports =
600611
TcImports.BuildFrameworkTcImports(foundationalTcConfigP, sysRes, otherRes)
@@ -604,10 +615,13 @@ let main1
604615
[
605616
for sourceFile in sourceFiles -> tcGlobals.memoize_file (FileIndex.fileIndexOfFile sourceFile)
606617
]
607-
618+
608619
// Register framework tcImports to be disposed in future
609620
disposables.Register frameworkTcImports
610-
621+
basic.Dispose()
622+
623+
let parse = new Timer("Parse sourceFiles")
624+
611625
// Parse sourceFiles
612626
ReportTime tcConfig "Parse inputs"
613627
use unwindParsePhase = UseBuildPhase BuildPhase.Parse
@@ -620,7 +634,7 @@ let main1
620634
||> List.mapFold (fun state (input, x) ->
621635
let inputT, stateT = DeduplicateParsedInputModuleName state input
622636
(inputT, x), stateT)
623-
637+
624638
// Print the AST if requested
625639
if tcConfig.printAst then
626640
for input, _filename in inputs do
@@ -633,7 +647,10 @@ let main1
633647

634648
if not tcConfig.continueAfterParseFailure then
635649
AbortOnError(diagnosticsLogger, exiter)
650+
651+
parse.Dispose()
636652

653+
let importOther = new Timer("Import other assemblies")
637654
// Apply any nowarn flags
638655
let tcConfig =
639656
(tcConfig, inputs)
@@ -658,6 +675,9 @@ let main1
658675
if tcConfig.importAllReferencesOnly then
659676
exiter.Exit 0
660677

678+
importOther.Dispose()
679+
680+
let typeCheck = new Timer("Typecheck")
661681
// Build the initial type checking environment
662682
ReportTime tcConfig "Typecheck"
663683

@@ -675,6 +695,8 @@ let main1
675695
AbortOnError(diagnosticsLogger, exiter)
676696
ReportTime tcConfig "Typechecked"
677697

698+
typeCheck.Dispose()
699+
678700
Args(
679701
ctok,
680702
tcGlobals,
@@ -710,7 +732,7 @@ let main2
710732
exiter: Exiter,
711733
ilSourceDocs))
712734
=
713-
735+
use _ = new Timer("main2")
714736
if tcConfig.typeCheckOnly then
715737
exiter.Exit 0
716738

@@ -818,7 +840,7 @@ let main3
818840
exiter: Exiter,
819841
ilSourceDocs))
820842
=
821-
843+
use _ = new Timer("main3")
822844
// Encode the signature data
823845
ReportTime tcConfig "Encode Interface Data"
824846
let exportRemapping = MakeExportRemapping generatedCcu generatedCcu.Contents
@@ -914,7 +936,7 @@ let main4
914936
exiter: Exiter,
915937
ilSourceDocs))
916938
=
917-
939+
use _ = new Timer("main4")
918940
match tcImportsCapture with
919941
| None -> ()
920942
| Some f -> f tcImports
@@ -1017,7 +1039,7 @@ let main5
10171039
exiter: Exiter,
10181040
ilSourceDocs))
10191041
=
1020-
1042+
use _ = new Timer("main5")
10211043
use _ = UseBuildPhase BuildPhase.Output
10221044

10231045
// Static linking, if any
@@ -1049,7 +1071,7 @@ let main6
10491071
exiter: Exiter,
10501072
ilSourceDocs))
10511073
=
1052-
1074+
use _ = new Timer("main6")
10531075
ReportTime tcConfig "Write .NET Binary"
10541076

10551077
use _ = UseBuildPhase BuildPhase.Output

src/fsc/fscmain.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module internal FSharp.Compiler.CommandLineMain
44

55
open System
6+
67
open System.Reflection
78
open System.Runtime
89
open System.Runtime.CompilerServices
@@ -21,9 +22,20 @@ open FSharp.Compiler.Text
2122
[<Dependency("FSharp.Compiler.Service", LoadHint.Always)>]
2223
do ()
2324

25+
26+
type Timer(name : string) =
27+
let sw = System.Diagnostics.Stopwatch.StartNew()
28+
do printfn $"{name} - start"
29+
member this.Dispose() = printfn $"{name} - end - {sw.Elapsed.TotalSeconds}s"
30+
interface IDisposable with
31+
member this.Dispose() = this.Dispose()
32+
33+
2434
[<EntryPoint>]
2535
let main (argv) =
2636

37+
use _ = new Timer("main")
38+
2739
let compilerName =
2840
// the 64 bit desktop version of the compiler is name fscAnyCpu.exe, all others are fsc.exe
2941
if

0 commit comments

Comments
 (0)