Skip to content

Instantly share code, notes, and snippets.

@manofstick
Created July 4, 2018 09:51
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 manofstick/847922bcce2e2f47d3eca033ed9dc068 to your computer and use it in GitHub Desktop.
Save manofstick/847922bcce2e2f47d3eca033ed9dc068 to your computer and use it in GitHub Desktop.
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