Skip to content

Instantly share code, notes, and snippets.

@delneg
Created December 14, 2020 22:50
Show Gist options
  • Save delneg/aa91b360b9df731b3be0131d8b6029cd to your computer and use it in GitHub Desktop.
Save delneg/aa91b360b9df731b3be0131d8b6029cd to your computer and use it in GitHub Desktop.
module Bench
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
[<SimpleJob(launchCount = 3, warmupCount = 3, targetCount = 5)>]
[<GcServer(true)>]
[<MemoryDiagnoser>]
[<MarkdownExporterAttribute.GitHub>]
type Benchmarks () =
[<Benchmark>]
member this.MapFst () =
let m = Map.ofArray [| for x in 1..10_000_000 -> x,string x |]
let keys = m |> Map.toSeq |> Seq.map fst
printfn "%i" (keys |> Seq.length)
[<Benchmark>]
member this.MapKeyValue () =
let m = Map.ofArray [| for x in 1..10_000_000 -> x,string x |]
let keys = m |> Seq.map (fun (KeyValue(key,_)) -> key)
printfn "%i" (keys |> Seq.length)
[<EntryPoint>]
let main _ =
let _ = BenchmarkRunner.Run<Benchmarks>()
0

// * Summary *

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.14393.2248 (1607/AnniversaryUpdate/Redstone1) AMD Ryzen 7 3800X, 1 CPU, 16 logical and 8 physical cores Frequency=3808597 Hz, Resolution=262.5639 ns, Timer=TSC .NET Core SDK=5.0.101 [Host] : .NET Core 5.0.1 (CoreCLR 5.0.120.57516, CoreFX 5.0.120.57516), X64 RyuJIT DEBUG Job-WCUQBY : .NET Core 5.0.1 (CoreCLR 5.0.120.57516, CoreFX 5.0.120.57516), X64 RyuJIT

Server=True IterationCount=5 LaunchCount=3
WarmupCount=3

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
MapFst 17.28 s 0.056 s 0.049 s 6000.0000 2000.0000 1000.0000 12.46 GB
MapKeyValue 16.85 s 0.185 s 0.164 s 6000.0000 2000.0000 1000.0000 12.46 GB

// * Hints * Outliers Benchmarks.MapFst: Server=True, IterationCount=5, LaunchCount=3, WarmupCount=3 -> 1 outlier was removed (17.45 s) Benchmarks.MapKeyValue: Server=True, IterationCount=5, LaunchCount=3, WarmupCount=3 -> Something went wrong with outliers: Size(WorkloadActual) = 15, Size(WorkloadActual/Outliers) = 0, Size(Result) = 14), OutlierMode = RemoveU pper

// * Legends * Mean : Arithmetic mean of all measurements Error : Half of 99.9% confidence interval StdDev : Standard deviation of all measurements Gen 0 : GC Generation 0 collects per 1000 operations Gen 1 : GC Generation 1 collects per 1000 operations Gen 2 : GC Generation 2 collects per 1000 operations Allocated : Allocated memory per single operation (managed only, inclusive, 1KB = 1024B) 1 s : 1 Second (1 sec)

// * Diagnostic Output - MemoryDiagnoser *

// ***** BenchmarkRunner: End ***** // ** Remained 0 benchmark(s) to run ** Run time: 00:17:17 (1037.31 sec), executed benchmarks: 2

Global total time: 00:17:32 (1052.61 sec), executed benchmarks: 2 // * Artifacts cleanup *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment