diff --git a/VisualFSharp.sln b/VisualFSharp.sln index b6e700de8cd..c5442391328 100644 --- a/VisualFSharp.sln +++ b/VisualFSharp.sln @@ -191,6 +191,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.Editor.IntegrationTe EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Benchmarks.Common", "tests\benchmarks\FSharp.Benchmarks.Common\FSharp.Benchmarks.Common.fsproj", "{6734FC6F-B5F3-45E1-9A72-720378BB49C9}" EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "MicroPerf", "tests\benchmarks\CompiledCodeBenchmarks\MicroPerf\MicroPerf.fsproj", "{601CD5C1-EAFA-4AE3-8FB9-F667B5728213}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MicroPerfCSharp", "tests\benchmarks\CompiledCodeBenchmarks\MicroPerf\CS\MicroPerfCSharp.csproj", "{9F9DD315-37DA-4413-928E-1CFC6924B64F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1005,6 +1009,30 @@ Global {6734FC6F-B5F3-45E1-9A72-720378BB49C9}.Release|Any CPU.Build.0 = Release|Any CPU {6734FC6F-B5F3-45E1-9A72-720378BB49C9}.Release|x86.ActiveCfg = Release|Any CPU {6734FC6F-B5F3-45E1-9A72-720378BB49C9}.Release|x86.Build.0 = Release|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Debug|Any CPU.Build.0 = Debug|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Debug|x86.ActiveCfg = Debug|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Debug|x86.Build.0 = Debug|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Proto|Any CPU.ActiveCfg = Debug|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Proto|Any CPU.Build.0 = Debug|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Proto|x86.ActiveCfg = Debug|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Proto|x86.Build.0 = Debug|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Release|Any CPU.ActiveCfg = Release|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Release|Any CPU.Build.0 = Release|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Release|x86.ActiveCfg = Release|Any CPU + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213}.Release|x86.Build.0 = Release|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Debug|x86.ActiveCfg = Debug|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Debug|x86.Build.0 = Debug|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Proto|Any CPU.ActiveCfg = Debug|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Proto|Any CPU.Build.0 = Debug|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Proto|x86.ActiveCfg = Debug|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Proto|x86.Build.0 = Debug|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|Any CPU.Build.0 = Release|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|x86.ActiveCfg = Release|Any CPU + {9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1084,6 +1112,8 @@ Global {CBC96CC7-65AB-46EA-A82E-F6A788DABF80} = {F7876C9B-FB6A-4EFB-B058-D6967DB75FB2} {E31F9B59-FCF1-4D04-8762-C7BB60285A7B} = {F7876C9B-FB6A-4EFB-B058-D6967DB75FB2} {6734FC6F-B5F3-45E1-9A72-720378BB49C9} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B} + {601CD5C1-EAFA-4AE3-8FB9-F667B5728213} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B} + {9F9DD315-37DA-4413-928E-1CFC6924B64F} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {48EDBBBE-C8EE-4E3C-8B19-97184A487B37} diff --git a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/Benchmarks.fs b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/Benchmarks.fs deleted file mode 100644 index cce09739135..00000000000 --- a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/Benchmarks.fs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MicroPerf - -open BenchmarkDotNet.Running - -module Main = - - [] - let main args = - printfn "Running benchmarks..." - BenchmarkSwitcher.FromAssembly(typeof.Assembly).Run(args) |> ignore - 0 diff --git a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/ComputedCollections/Arrays/IntegralRanges.fs b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/ComputedCollections/Arrays/IntegralRanges.fs new file mode 100644 index 00000000000..645ce31c646 --- /dev/null +++ b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/ComputedCollections/Arrays/IntegralRanges.fs @@ -0,0 +1,653 @@ +module MicroPerf.ComputedCollections.Arrays.IntegralRanges + +open BenchmarkDotNet.Attributes + +#nowarn "77" + +let inline (~~) x = (^a : (static member op_Explicit : int -> ^a) x) + +module All = + let inline ``[|start..finish|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member One : 'a) + and 'a : comparison> + (start : 'a) (finish : 'a) + = + [|start..finish|] + + let inline ``[|start..step..finish|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member Zero : 'a) + and 'a : (static member One : 'a) + and 'a : comparison> + (start : 'a) (step : 'a) (finish : 'a) + = + [|start..step..finish|] + + let inline ``[|for n in start..finish -> n|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member One : 'a) + and 'a : comparison> + (start : 'a) (finish : 'a) + = + [|for n in start..finish -> n|] + + let inline ``[|for n in start..step..finish -> n|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member Zero : 'a) + and 'a : (static member One : 'a) + and 'a : comparison> + (start : 'a) (step : 'a) (finish : 'a) + = + [|for n in start..step..finish -> n|] + + let inline ``[|1..127|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member One : 'a) + and 'a : comparison + and 'a : (static member op_Explicit : int -> 'a)> () = + ``[|start..finish|]``<'a> ~~1 ~~127 + + let inline ``[|1..2..127|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member Zero : 'a) + and 'a : (static member One : 'a) + and 'a : (static member op_Explicit : int -> 'a) + and 'a : comparison> () = + ``[|start..step..finish|]``<'a> ~~1 ~~2 ~~127 + + let inline ``[|127..1|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member One : 'a) + and 'a : comparison + and 'a : (static member op_Explicit : int -> 'a)> () = + ``[|start..finish|]``<'a> ~~127 ~~1 + + let inline ``[|127..2..1|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member Zero : 'a) + and 'a : (static member One : 'a) + and 'a : (static member op_Explicit : int -> 'a) + and 'a : comparison> () = + ``[|start..step..finish|]``<'a> ~~127 ~~2 ~~1 + + let inline ``[|1..32767|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member One : 'a) + and 'a : comparison + and 'a : (static member op_Explicit : int -> 'a)> () = + ``[|start..finish|]``<'a> ~~1 ~~32767 + + let inline ``[|1..2..32767|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member Zero : 'a) + and 'a : (static member One : 'a) + and 'a : (static member op_Explicit : int -> 'a) + and 'a : comparison> () = + ``[|start..step..finish|]``<'a> ~~1 ~~2 ~~32767 + +module Signed = + let inline ``[|127..-1..-128|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member (~-) : 'a -> 'a) + and 'a : (static member One : 'a) + and 'a : (static member Zero : 'a) + and 'a : (static member op_Explicit : int -> 'a) + and 'a : comparison> () = + All.``[|start..step..finish|]``<'a> ~~127 (- ~~1) (- ~~128) + + let inline ``[|127..-2..-128|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member (~-) : 'a -> 'a) + and 'a : (static member One : 'a) + and 'a : (static member Zero : 'a) + and 'a : (static member op_Explicit : int -> 'a) + and 'a : comparison> () = + All.``[|start..step..finish|]``<'a> ~~127 (- ~~2) (- ~~128) + + let inline ``[|32767..-1..-32768|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member (~-) : 'a -> 'a) + and 'a : (static member One : 'a) + and 'a : (static member Zero : 'a) + and 'a : (static member op_Explicit : int -> 'a) + and 'a : comparison> () = + All.``[|start..step..finish|]``<'a> ~~32767 (- ~~1) (- ~~32768) + + let inline ``[|32767..-2..-32768|]``<'a + when 'a : (static member (+) : 'a * 'a -> 'a) + and 'a : (static member (~-) : 'a -> 'a) + and 'a : (static member One : 'a) + and 'a : (static member Zero : 'a) + and 'a : (static member op_Explicit : int -> 'a) + and 'a : comparison> () = + All.``[|start..step..finish|]``<'a> ~~32767 (- ~~2) (- ~~32769) + +[] +type ComputedCollections_Arrays_IntegralRanges_SByte () = + member _.StartFinish : obj array seq = + [ + [|-128y; 127y|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|127y; -1y; -128y|] + [|-128y; 2y; 127y|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = Signed.``[|127..-1..-128|]`` () + + [] + member _.M6 () = Signed.``[|127..-2..-128|]`` () + + [] + [.StartFinish)>] + member _.M7 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M8 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M9 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M10 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_Byte () = + member _.StartFinish : obj array seq = + [ + [|box 0uy; 255uy|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|box 0uy; 2uy; 255uy|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + [.StartFinish)>] + member _.M5 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M6 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M7 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M8 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_Char () = + member _.StartFinish : obj array seq = + [ + [|'\000'; '\u7fff'|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|'\000'; '\002'; '\u7fff'|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = All.``[|1..32767|]`` () + + [] + member _.M6 () = All.``[|1..2..32767|]`` () + + [] + [.StartFinish)>] + member _.M7 (start : char) finish = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M8 (start : char) step finish = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M9 (start : char) finish = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M10 (start : char) step finish = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_Int16 () = + member _.StartFinish : obj array seq = + [ + [|-32768s; 32767s|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|32767s; -1s; -32768s|] + [|-32768s; 2s; 32767s|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = All.``[|1..32767|]`` () + + [] + member _.M6 () = All.``[|1..2..32767|]`` () + + [] + member _.M7 () = Signed.``[|32767..-1..-32768|]`` () + + [] + member _.M8 () = Signed.``[|32767..-2..-32768|]`` () + + [] + [.StartFinish)>] + member _.M9 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M10 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M11 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M12 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_UInt16 () = + member _.StartFinish : obj array seq = + [ + [|box 0us; 32767us|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|box 0us; 2us; 32767us|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = All.``[|1..32767|]`` () + + [] + member _.M6 () = All.``[|1..2..32767|]`` () + + [] + [.StartFinish)>] + member _.M7 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M8 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M9 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M10 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_Int32 () = + member _.StartFinish : obj array seq = + [ + [|-32768; 32767|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|32767; -1; -32768|] + [|-32768; 2; 32767|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = All.``[|1..32767|]`` () + + [] + member _.M6 () = All.``[|1..2..32767|]`` () + + [] + member _.M7 () = Signed.``[|32767..-1..-32768|]`` () + + [] + member _.M8 () = Signed.``[|32767..-2..-32768|]`` () + + [] + [.StartFinish)>] + member _.M9 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M10 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M11 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M12 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_UInt32 () = + member _.StartFinish : obj array seq = + [ + [|0u; 32767u|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|0u; 2u; 32767u|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = All.``[|1..32767|]`` () + + [] + member _.M6 () = All.``[|1..2..32767|]`` () + + [] + [.StartFinish)>] + member _.M7 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M8 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M9 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M10 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_Int64 () = + member _.StartFinish : obj array seq = + [ + [|-32768L; 32767L|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|32767L; -1L; -32768L|] + [|-32768L; 2L; 32767L|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = All.``[|1..32767|]`` () + + [] + member _.M6 () = All.``[|1..2..32767|]`` () + + [] + member _.M7 () = Signed.``[|32767..-1..-32768|]`` () + + [] + member _.M8 () = Signed.``[|32767..-2..-32768|]`` () + + [] + [.StartFinish)>] + member _.M9 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M10 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M11 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M12 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_UInt64 () = + member _.StartFinish : obj array seq = + [ + [|0UL; 32767UL|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|0UL; 2UL; 32767UL|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = All.``[|1..32767|]`` () + + [] + member _.M6 () = All.``[|1..2..32767|]`` () + + [] + [.StartFinish)>] + member _.M7 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M8 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M9 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M10 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_IntPtr () = + member _.StartFinish : obj array seq = + [ + [|-32768n; 32767n|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|32767n; -1n; -32768n|] + [|-32768n; 2n; 32767n|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = All.``[|1..32767|]`` () + + [] + member _.M6 () = All.``[|1..2..32767|]`` () + + [] + member _.M7 () = Signed.``[|32767..-1..-32768|]`` () + + [] + member _.M8 () = Signed.``[|32767..-2..-32768|]`` () + + [] + [.StartFinish)>] + member _.M9 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M10 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M11 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M12 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish + +[] +type ComputedCollections_Arrays_IntegralRanges_UIntPtr () = + member _.StartFinish : obj array seq = + [ + [|0un; 32767un|] + ] + + member _.StartStepFinish : obj array seq = + [ + [|0un; 2un; 32767un|] + ] + + [] + member _.M1 () = All.``[|127..1|]`` () + + [] + member _.M2 () = All.``[|127..2..1|]`` () + + [] + member _.M3 () = All.``[|1..127|]`` () + + [] + member _.M4 () = All.``[|1..2..127|]`` () + + [] + member _.M5 () = All.``[|1..32767|]`` () + + [] + member _.M6 () = All.``[|1..2..32767|]`` () + + [] + [.StartFinish)>] + member _.M7 (start, finish) = All.``[|start..finish|]`` start finish + + [] + [.StartStepFinish)>] + member _.M8 (start, step, finish) = All.``[|start..step..finish|]`` start step finish + + [ n|]")>] + [.StartFinish)>] + member _.M9 (start, finish) = All.``[|for n in start..finish -> n|]`` start finish + + [ n|]")>] + [.StartStepFinish)>] + member _.M10 (start, step, finish) = All.``[|for n in start..step..finish -> n|]`` start step finish diff --git a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/MicroPerf.fsproj b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/MicroPerf.fsproj index 9fc704b2ce5..2cbfaf0aaba 100644 --- a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/MicroPerf.fsproj +++ b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/MicroPerf.fsproj @@ -1,14 +1,20 @@  + Exe - $(OtherFlags) --nowarn:1204 - $(OtherFlags) --nowarn:57 - $(OtherFlags) --langversion:preview - $(OtherFlags) --define:PREVIEW + $(NoWarn);1204;57 + true + + + $(MSBuildThisFileDirectory)../../../../artifacts/bin/fsc/Release/$(TargetFramework)/fsc.dll + preview + + + @@ -21,9 +27,22 @@ - - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/Program.fs b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/Program.fs new file mode 100644 index 00000000000..574f186dd3e --- /dev/null +++ b/tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/Program.fs @@ -0,0 +1,16 @@ +module MicroPerf.Program + +open System +open System.Reflection +open BenchmarkDotNet.Configs +open BenchmarkDotNet.Jobs +open BenchmarkDotNet.Running + +let config = + DefaultConfig.Instance + .AddJob(Job.Default.WithId("Current").WithArguments([|MsBuildArgument "/p:BUILDING_USING_DOTNET=true"|]).AsBaseline()) + .AddJob(Job.Default.WithId("Preview").WithArguments([|MsBuildArgument "/p:BUILDING_USING_DOTNET=true"|]).WithCustomBuildConfiguration "Preview") + .WithOptions(ConfigOptions.JoinSummary) + .HideColumns("BuildConfiguration") + +ignore (BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(Environment.GetCommandLineArgs(), config)) diff --git a/tests/benchmarks/CompiledCodeBenchmarks/README.md b/tests/benchmarks/CompiledCodeBenchmarks/README.md new file mode 100644 index 00000000000..80ccf5eba90 --- /dev/null +++ b/tests/benchmarks/CompiledCodeBenchmarks/README.md @@ -0,0 +1,58 @@ +# Compiled Code Benchmarks + +This benchmarks project is meant to be used to test the performance of code generated by the F# compiler. It is set up so that, by default, it will build and run your benchmarks in two jobs: + +- The first will be built using the local compiler targeting the current language version and will be used as the baseline. +- The second will be built using the local compiler targeting the `preview` language version. + +Note that the intent is generally that you use this project to benchmark your changes locally. Most of the time, you will not need to check in your benchmarks. + +#### Build the repo with the `Release` config + +```pwsh +./Build.cmd -c Release +``` + +#### Run the benchmarks + +```pwsh +dotnet run --project .\tests\benchmarks\CompiledCodeBenchmarks\MicroPerf\MicroPerf.fsproj -c Release +``` + +The benchmark switcher will prompt you to choose which benchmark or benchmarks you want to run. + +#### Sample output + +```console +| Job | Categories | start | finish | step | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio | +|-------- |--------------------------------------------------------------------------------------- |------ |------- |----- |---------------:|--------------:|--------------:|---------------:|------:|--------:|-------:|-------:|-------:|----------:|------------:| +| Current | UInt32,[|127u..1u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 24.046 ns | 0.4269 ns | 0.3993 ns | 23.985 ns | 1.00 | 0.00 | 0.0004 | - | - | 96 B | 1.00 | +| Preview | UInt32,[|127u..1u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 1.729 ns | 0.0804 ns | 0.0752 ns | 1.725 ns | 0.07 | 0.00 | - | - | - | - | 0.00 | +| | | | | | | | | | | | | | | | | +| Current | UInt32,[|127u..2u..1u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 22.817 ns | 0.2053 ns | 0.1920 ns | 22.760 ns | 1.00 | 0.00 | 0.0004 | - | - | 96 B | 1.00 | +| Preview | UInt32,[|127u..2u..1u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 3.161 ns | 0.1053 ns | 0.0985 ns | 3.172 ns | 0.14 | 0.00 | - | - | - | - | 0.00 | +| | | | | | | | | | | | | | | | | +| Current | UInt32,[|1u..127u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 361.493 ns | 4.3161 ns | 3.8261 ns | 361.798 ns | 1.00 | 0.00 | 0.0072 | - | - | 1768 B | 1.00 | +| Preview | UInt32,[|1u..127u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 96.560 ns | 1.9609 ns | 3.6347 ns | 94.721 ns | 0.27 | 0.01 | 0.0021 | - | - | 536 B | 0.30 | +| | | | | | | | | | | | | | | | | +| Current | UInt32,[|1u..2u..127u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 263.240 ns | 3.4600 ns | 2.8893 ns | 264.086 ns | 1.00 | 0.00 | 0.0029 | - | - | 712 B | 1.00 | +| Preview | UInt32,[|1u..2u..127u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 58.053 ns | 1.1757 ns | 1.6481 ns | 57.840 ns | 0.22 | 0.01 | 0.0011 | - | - | 280 B | 0.39 | +| | | | | | | | | | | | | | | | | +| Current | UInt32,[|1u..2u..32767u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 40,529.790 ns | 272.6267 ns | 241.6764 ns | 40,486.288 ns | 1.00 | 0.00 | 0.4883 | - | - | 131464 B | 1.00 | +| Preview | UInt32,[|1u..2u..32767u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 7,787.907 ns | 152.9334 ns | 176.1183 ns | 7,737.320 ns | 0.19 | 0.00 | 0.2747 | - | - | 65560 B | 0.50 | +| | | | | | | | | | | | | | | | | +| Current | UInt32,[|1u..32767u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 256,084.235 ns | 5,074.6636 ns | 6,598.4961 ns | 257,729.980 ns | 1.00 | 0.00 | 8.3008 | 8.3008 | 8.3008 | 393680 B | 1.00 | +| Preview | UInt32,[|1u..32767u|],ComputedCollections,Arrays,IntegralRanges | ? | ? | ? | 77,660.979 ns | 1,541.8822 ns | 4,399.0768 ns | 77,866.278 ns | 0.31 | 0.02 | 2.8076 | 2.8076 | 2.8076 | 131088 B | 0.33 | +| | | | | | | | | | | | | | | | | +| Current | UInt32,[|for n in start..finish -> n|],ComputedCollections,Arrays,IntegralRanges | 0 | 32767 | ? | 281,373.636 ns | 5,097.5675 ns | 4,518.8608 ns | 282,881.763 ns | 1.00 | 0.00 | 8.7891 | 8.7891 | 8.7891 | 393741 B | 1.00 | +| Preview | UInt32,[|for n in start..finish -> n|],ComputedCollections,Arrays,IntegralRanges | 0 | 32767 | ? | 77,629.964 ns | 1,545.8980 ns | 4,509.4572 ns | 77,968.518 ns | 0.29 | 0.02 | 3.0518 | 3.0518 | 3.0518 | 131090 B | 0.33 | +| | | | | | | | | | | | | | | | | +| Current | UInt32,[|for n in start..step..finish -> n|],ComputedCollections,Arrays,IntegralRanges | 0 | 32767 | 2 | 69,948.064 ns | 1,078.6284 ns | 1,154.1203 ns | 69,834.222 ns | 1.00 | 0.00 | 0.7324 | - | - | 197056 B | 1.00 | +| Preview | UInt32,[|for n in start..step..finish -> n|],ComputedCollections,Arrays,IntegralRanges | 0 | 32767 | 2 | 7,700.286 ns | 115.4058 ns | 107.9507 ns | 7,679.921 ns | 0.11 | 0.00 | 0.2747 | - | - | 65560 B | 0.33 | +| | | | | | | | | | | | | | | | | +| Current | UInt32,[|start..finish|],ComputedCollections,Arrays,IntegralRanges | 0 | 32767 | ? | 148,726.931 ns | 2,956.8132 ns | 4,603.4019 ns | 148,672.632 ns | 1.00 | 0.00 | 4.8828 | 4.3945 | 4.3945 | 262584 B | 1.00 | +| Preview | UInt32,[|start..finish|],ComputedCollections,Arrays,IntegralRanges | 0 | 32767 | ? | 77,915.564 ns | 1,554.2518 ns | 3,476.3069 ns | 77,861.060 ns | 0.52 | 0.03 | 4.0283 | 4.0283 | 4.0283 | 131095 B | 0.50 | +| | | | | | | | | | | | | | | | | +| Current | UInt32,[|start..step..finish|],ComputedCollections,Arrays,IntegralRanges | 0 | 32767 | 2 | 38,456.304 ns | 682.2118 ns | 638.1413 ns | 38,380.719 ns | 1.00 | 0.00 | 0.4883 | - | - | 131464 B | 1.00 | +| Preview | UInt32,[|start..step..finish|],ComputedCollections,Arrays,IntegralRanges | 0 | 32767 | 2 | 7,791.339 ns | 93.7728 ns | 87.7152 ns | 7,789.114 ns | 0.20 | 0.00 | 0.2747 | - | - | 65560 B | 0.50 | +``` \ No newline at end of file