Created
June 9, 2018 04:29
-
-
Save manofstick/d54cf0e11265e10fa0480f18c3dea8a5 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
module Program | |
open Perf | |
open System | |
open System.Diagnostics | |
[<EntryPoint>] | |
let main argv = | |
printfn "%s" Id.Name | |
// create lots of lists to try not to get cache benefits | |
let lists = | |
Array.init 1000000 (fun i -> | |
List.init 10 (fun j -> | |
if i % 2 = 0 then -j else j)) | |
let sw = Stopwatch.StartNew () | |
let r = Random 42 | |
let mutable count = 0 | |
for i=0 to 1000000 do | |
let a = lists.[r.Next lists.Length] | |
let b = lists.[r.Next lists.Length] | |
count <- count + if a = b then 1 else 0 | |
printfn "%A (%A)" sw.ElapsedMilliseconds count | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment