Skip to content

Instantly share code, notes, and snippets.

@liboz
Created July 25, 2016 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liboz/d1d513c378aefbc78889f2db27f2800f to your computer and use it in GitHub Desktop.
Save liboz/d1d513c378aefbc78889f2db27f2800f to your computer and use it in GitHub Desktop.
groupByBenchmarkDotNet
open BenchmarkDotNet.Running
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Configs
open BenchmarkDotNet.Diagnostics.Windows
type groupBy () =
[<Params(10, 100, 10000, 1000000, 10000000)>]
member val public count = 0 with get, set
[<Benchmark>]
member this.groupByModulus () =
List.groupBy (fun i -> i % 2) [1..this.count]
[<Benchmark>]
member this.groupByOriginalModulus () =
List.groupBy2 (fun i -> i % 2) [1..this.count]
[<Benchmark>]
member this.groupBy () =
List.groupBy id [1..this.count]
[<Benchmark>]
member this.groupByOriginal () =
List.groupBy2 id [1..this.count]
[<Benchmark>]
member this.groupByMixed () =
List.groupBy (fun i -> i % 2) (List.concat [[1..this.count]; [1..(max 10000 this.count/2)]; [1..(max 10000 this.count/2)]])
[<Benchmark>]
member this.groupByOriginalMixed () =
List.groupBy2 (fun i -> i % 2) (List.concat [[1..this.count]; [1..(max 10000 this.count/2)]; [1..(max 10000 this.count/2)]])
let [<EntryPoint>] main args =
let config = ManualConfig.Create(DefaultConfig.Instance)
config.Add(new MemoryDiagnoser())
config.Add(new InliningDiagnoser())
BenchmarkRunner.Run<groupBy>(config) |> ignore
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment