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
let mapFold (f:'a -> 'b -> 'c * 'a) (s:'a) (l:'b list) : 'c list * 'a = | |
// microbenchmark suggested this implementation is faster than the simpler recursive one, and this function is called a lot | |
let mutable s = s | |
let mutable r = [] | |
for x in l do | |
let x',s' = f s x | |
s <- s' | |
r <- x' :: r | |
List.rev r, s |
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 | |
open BenchmarkDotNet.Jobs | |
open System.Linq | |
type map () = | |
[<Params(10, 100, 10000)>] | |
member val public count = 0 with get, set |
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 | |
open BenchmarkDotNet.Jobs | |
open System.Collections.Generic | |
open System.Collections | |
open System |
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 scanOriginal<'T,'State> f (s:'State) (list:'T list) = | |
let f = OptimizedClosures.FSharpFunc<_,_,_>.Adapt(f) | |
let rec loop s xs acc = | |
match xs with | |
| [] -> List.rev acc |
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 rec chooseAllAcc f xs acc = | |
match xs with | |
| [] -> List.rev acc | |
| h :: t -> | |
match f h with |
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]) |
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 | |
type groupBy () = | |
[<Params(10, 100, 10000, 1000000, 10000000)>] | |
member val public count = 0 with get, set | |
[<Benchmark>] | |
member this.groupByModulus () = |
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 System.Diagnostics | |
let run (f : 'a -> 'b) l = | |
let res = f l | |
for i in 2..200 do | |
f l |> ignore | |
res | |
let count = 1000000 | |
let listOfInts = [1..count] |
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 System.Diagnostics | |
open System.Reflection | |
open Microsoft.FSharp.Core | |
open Microsoft.FSharp.Core.Operators | |
open Microsoft.FSharp.Core.LanguagePrimitives | |
open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators | |
open Microsoft.FSharp.Collections | |
open Microsoft.FSharp.Primitives.Basics | |
open System.Collections.Generic |