From 3f8bcb2120e75e842c8ab567ab2ee32cd087c11d Mon Sep 17 00:00:00 2001 From: Will Smith Date: Sat, 15 Dec 2018 15:13:27 -0800 Subject: [PATCH 1/3] Initial benchmarking --- benchmarks/Benchmarks.sln | 37 ++++++++++++ benchmarks/Benchmarks/Benchmarks.fsproj | 12 ++++ benchmarks/Benchmarks/Program.fs | 8 +++ .../CompilerServiceBenchmarks.fsproj | 21 +++++++ .../CompilerServiceBenchmarks/Program.fs | 60 +++++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 benchmarks/Benchmarks.sln create mode 100644 benchmarks/Benchmarks/Benchmarks.fsproj create mode 100644 benchmarks/Benchmarks/Program.fs create mode 100644 benchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fsproj create mode 100644 benchmarks/CompilerServiceBenchmarks/Program.fs diff --git a/benchmarks/Benchmarks.sln b/benchmarks/Benchmarks.sln new file mode 100644 index 00000000000..5d339f7a99f --- /dev/null +++ b/benchmarks/Benchmarks.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "CompilerServiceBenchmarks", "CompilerServiceBenchmarks\CompilerServiceBenchmarks.fsproj", "{9A3C565C-B514-4AE0-8B01-CA80E8453EB0}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Core", "..\src\fsharp\FSharp.Core\FSharp.Core.fsproj", "{BB9EAE76-194A-49D8-9618-586CBE7031D9}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Private", "..\src\fsharp\FSharp.Compiler.Private\FSharp.Compiler.Private.fsproj", "{F57B02B1-CF26-4D93-9211-8CEB4F1572F0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A3C565C-B514-4AE0-8B01-CA80E8453EB0}.Release|Any CPU.Build.0 = Release|Any CPU + {BB9EAE76-194A-49D8-9618-586CBE7031D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB9EAE76-194A-49D8-9618-586CBE7031D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB9EAE76-194A-49D8-9618-586CBE7031D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB9EAE76-194A-49D8-9618-586CBE7031D9}.Release|Any CPU.Build.0 = Release|Any CPU + {F57B02B1-CF26-4D93-9211-8CEB4F1572F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F57B02B1-CF26-4D93-9211-8CEB4F1572F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F57B02B1-CF26-4D93-9211-8CEB4F1572F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F57B02B1-CF26-4D93-9211-8CEB4F1572F0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {049A4D02-709F-418C-AD59-7FB0DBE956B1} + EndGlobalSection +EndGlobal diff --git a/benchmarks/Benchmarks/Benchmarks.fsproj b/benchmarks/Benchmarks/Benchmarks.fsproj new file mode 100644 index 00000000000..99c5133a5a3 --- /dev/null +++ b/benchmarks/Benchmarks/Benchmarks.fsproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp2.1 + + + + + + + diff --git a/benchmarks/Benchmarks/Program.fs b/benchmarks/Benchmarks/Program.fs new file mode 100644 index 00000000000..a7458f52201 --- /dev/null +++ b/benchmarks/Benchmarks/Program.fs @@ -0,0 +1,8 @@ +// Learn more about F# at http://fsharp.org + +open System + +[] +let main argv = + printfn "Hello World from F#!" + 0 // return an integer exit code diff --git a/benchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fsproj b/benchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fsproj new file mode 100644 index 00000000000..fcdd08995e3 --- /dev/null +++ b/benchmarks/CompilerServiceBenchmarks/CompilerServiceBenchmarks.fsproj @@ -0,0 +1,21 @@ + + + + Exe + net472 + + + + + + + + + + + + + + + + diff --git a/benchmarks/CompilerServiceBenchmarks/Program.fs b/benchmarks/CompilerServiceBenchmarks/Program.fs new file mode 100644 index 00000000000..f32bfbdaac5 --- /dev/null +++ b/benchmarks/CompilerServiceBenchmarks/Program.fs @@ -0,0 +1,60 @@ +open System +open System.IO +open BenchmarkDotNet.Attributes +open BenchmarkDotNet.Running +open Microsoft.FSharp.Compiler.ErrorLogger +open Microsoft.FSharp.Compiler.SourceCodeServices +open System.Text + +[] +type CompilerServiceParsing() = + + let mutable checkerOpt = None + + let mutable sourceOpt = None + + let parsingOptions = + { + SourceFiles = [|"TypeChecker.fs"|] + ConditionalCompilationDefines = [] + ErrorSeverityOptions = FSharpErrorSeverityOptions.Default + IsInteractive = false + LightSyntax = None + CompilingFsLib = false + IsExe = false + } + + [] + member __.Setup() = + match checkerOpt with + | None -> checkerOpt <- Some(FSharpChecker.Create()) + | _ -> () + + match sourceOpt with + | None -> + let source = File.ReadAllText("""C:\visualfsharp\src\fsharp\TypeChecker.fs""") + sourceOpt <- Some(source) + | _ -> () + + [] + member __.ParsingSetup() = + match checkerOpt with + | None -> failwith "no checker" + | Some(checker) -> + checker.InvalidateAll() + checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() + checker.ParseFile("dummy.fs", "dummy", parsingOptions) |> Async.RunSynchronously |> ignore + + [] + member __.Parsing() = + match checkerOpt, sourceOpt with + | None, _ -> failwith "no checker" + | _, None -> failwith "no source" + | Some(checker), Some(source) -> + let results = checker.ParseFile("TypeChecker.fs", source, parsingOptions) |> Async.RunSynchronously + if results.ParseHadErrors then failwithf "parse had errors: %A" results.Errors + +[] +let main argv = + let _ = BenchmarkRunner.Run() + 0 From e13a1ec8596a650cbac27d9cef2bfd3ab99db694 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Sat, 15 Dec 2018 15:51:41 -0800 Subject: [PATCH 2/3] Removing unused files --- benchmarks/Benchmarks/Benchmarks.fsproj | 12 ------------ benchmarks/Benchmarks/Program.fs | 8 -------- 2 files changed, 20 deletions(-) delete mode 100644 benchmarks/Benchmarks/Benchmarks.fsproj delete mode 100644 benchmarks/Benchmarks/Program.fs diff --git a/benchmarks/Benchmarks/Benchmarks.fsproj b/benchmarks/Benchmarks/Benchmarks.fsproj deleted file mode 100644 index 99c5133a5a3..00000000000 --- a/benchmarks/Benchmarks/Benchmarks.fsproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - netcoreapp2.1 - - - - - - - diff --git a/benchmarks/Benchmarks/Program.fs b/benchmarks/Benchmarks/Program.fs deleted file mode 100644 index a7458f52201..00000000000 --- a/benchmarks/Benchmarks/Program.fs +++ /dev/null @@ -1,8 +0,0 @@ -// Learn more about F# at http://fsharp.org - -open System - -[] -let main argv = - printfn "Hello World from F#!" - 0 // return an integer exit code From 3974de0c5e3a19935eb33dbb23502e9a7a98399e Mon Sep 17 00:00:00 2001 From: Will Smith Date: Sat, 15 Dec 2018 16:38:42 -0800 Subject: [PATCH 3/3] Fixing path --- benchmarks/CompilerServiceBenchmarks/Program.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/CompilerServiceBenchmarks/Program.fs b/benchmarks/CompilerServiceBenchmarks/Program.fs index f32bfbdaac5..d5e45275775 100644 --- a/benchmarks/CompilerServiceBenchmarks/Program.fs +++ b/benchmarks/CompilerServiceBenchmarks/Program.fs @@ -32,7 +32,7 @@ type CompilerServiceParsing() = match sourceOpt with | None -> - let source = File.ReadAllText("""C:\visualfsharp\src\fsharp\TypeChecker.fs""") + let source = File.ReadAllText("""..\..\..\..\..\src\fsharp\TypeChecker.fs""") sourceOpt <- Some(source) | _ -> ()