Created
July 4, 2018 09:51
-
-
Save manofstick/847922bcce2e2f47d3eca033ed9dc068 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)) | |
for i = 1 to 5 do | |
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