-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
This week at #Build2016 F# support for .NET Core was announced. I have grabbed our code to check what is needed to be done to get it working. It turns out that we already support it!! Mainly due to the reuse of dotnet cli features.
So I just added sample F# benchmark to our repo, it can be found here I have reused existing F# sample.
project.json:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true,
"optimize": true
},
"compilerName": "fsc",
"compileFiles": [
"Program.fs"
],
"commands": {
"run": "BenchmarkDotNet.Samples.FSharp"
},
"dependencies": {
"BenchmarkDotNet": {
"target": "package",
"version": "0.9.4-beta"
},
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-151221",
"NETStandard.Library": "1.0.0-rc2-23811"
},
"frameworks": {
"dnxcore50": { }
}
}Program.fs
module Program
open System
open System.IO
open System.Collections.Concurrent
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
let getStrings len = Array.init len (fun _ -> Path.GetRandomFileName())
let lookup arr (dict:ConcurrentDictionary<string,bool>) =
arr |> Array.iteri(fun idx elm ->
let mutable b = dict.[elm]
b <- dict.[arr.[0]])
type StringKeyComparison () =
let mutable arr : string [] = [||]
let dict1 = ConcurrentDictionary<_,_>()
let dict2 = ConcurrentDictionary<_,_>(StringComparer.Ordinal)
[<Params (100, 500, 1000, 2000)>]
member val public DictSize = 0 with get, set
[<Setup>]
member self.SetupData() =
dict1.Clear(); dict2.Clear()
arr <- getStrings self.DictSize
arr |> Array.iter (fun x -> dict1.[x] <- true ; dict2.[x] <- true)
[<Benchmark>]
member self.StandardLookup () = lookup arr dict1
[<Benchmark>]
member self.OrdinalLookup () = lookup arr dict2
let defaultSwitch () = BenchmarkSwitcher [| typeof<StringKeyComparison> |]
[<EntryPoint>]
let Main args =
defaultSwitch().Run args
0
NuGet.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="fsharp-daily" value="https://www.myget.org/F/fsharp-daily/api/v3/index.json" />
</packageSources>
</configuration>commands needed to execute:
dotnet restore
dotnet run
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels