Last active
July 25, 2016 21:34
-
-
Save liboz/c0671b5e0ac855e26eef2a856d0f4547 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open BenchmarkDotNet.Running | |
open BenchmarkDotNet.Attributes | |
open BenchmarkDotNet.Configs | |
open BenchmarkDotNet.Diagnostics.Windows | |
let pairwiseOriginal (list: 'T list) = | |
let array = List.toArray list | |
if array.Length < 2 then [] else | |
List.init (array.Length-1) (fun i -> array.[i],array.[i+1]) | |
type pairwise () = | |
[<Params(10, 100, 10000, 1000000)>] | |
member val public count = 0 with get, set | |
[<Benchmark>] | |
member this.pairwise () = | |
List.pairwise [1..this.count] | |
[<Benchmark>] | |
member this.pairwiseOriginal () = | |
pairwiseOriginal [1..this.count] | |
[<Benchmark>] | |
member this.pairwiseString () = | |
List.pairwise [for i in 1..this.count -> i.ToString() ] | |
[<Benchmark>] | |
member this.pairwiseOriginalString () = | |
pairwiseOriginal [for i in 1..this.count -> i.ToString() ] | |
let [<EntryPoint>] main args = | |
let config = ManualConfig.Create(DefaultConfig.Instance) | |
config.Add(new MemoryDiagnoser()) | |
config.Add(new InliningDiagnoser()) | |
BenchmarkRunner.Run<pairwise>(config) |> ignore | |
0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment