Skip to content

Instantly share code, notes, and snippets.

@liboz
Last active August 16, 2016 01:10
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 liboz/d1f2ef35c9c46a5019127bd3b4f99d17 to your computer and use it in GitHub Desktop.
Save liboz/d1f2ef35c9c46a5019127bd3b4f99d17 to your computer and use it in GitHub Desktop.
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]
let listOfInts1 = List.concat [[1..count]; [1..10000]; [1..10000]]
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy id listOfInts //Real: 00:00:00.717, CPU: 00:00:00.718, GC gen0: 12, gen1: 11, gen2: 1
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy2 id listOfInts //Real: 00:00:01.423, CPU: 00:00:01.421, GC gen0: 22, gen1: 20, gen2: 1
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy2 id listOfInts //Real: 00:00:01.423, CPU: 00:00:01.421, GC gen0: 22, gen1: 20, gen2: 1
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy id listOfInts //Real: 00:00:00.717, CPU: 00:00:00.718, GC gen0: 12, gen1: 11, gen2: 1
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy2 (fun i -> i % 2) listOfInts //Real: 00:00:00.122, CPU: 00:00:00.125, GC gen0: 3, gen1: 2, gen2: 1
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy (fun i -> i % 2) listOfInts //Real: 00:00:00.134, CPU: 00:00:00.140, GC gen0: 3, gen1: 3, gen2: 0
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy (fun i -> i % 2) listOfInts //Real: 00:00:00.122, CPU: 00:00:00.125, GC gen0: 3, gen1: 2, gen2: 1
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy2 (fun i -> i % 2) listOfInts //Real: 00:00:00.134, CPU: 00:00:00.140, GC gen0: 3, gen1: 3, gen2: 0
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy id listOfInts1 //Real: 00:00:00.638, CPU: 00:00:00.640, GC gen0: 11, gen1: 11, gen2: 0
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy2 id listOfInts1 //Real: 00:00:01.136, CPU: 00:00:01.250, GC gen0: 22, gen1: 21, gen2: 1
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy2 id listOfInts1 //Real: 00:00:01.136, CPU: 00:00:01.250, GC gen0: 22, gen1: 21, gen2: 1
#time "off"
ignore <| System.GC.Collect()
ignore <| System.GC.WaitForPendingFinalizers ()
ignore <| System.GC.Collect()
#time "on"
run List.groupBy id listOfInts1 //Real: 00:00:00.638, CPU: 00:00:00.640, GC gen0: 11, gen1: 11, gen2: 0
#time "off"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment