Created
August 2, 2017 13:59
-
-
Save eiriktsarpalis/51d07322e4f957d09711c01f443c25dc to your computer and use it in GitHub Desktop.
Class vs Struct Index Performance
This file contains 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
#time "on" | |
open System | |
open System.Collections.Generic | |
let gdata = [|for i in 1 .. 1000000 -> Guid.NewGuid()|] | |
let sdata = gdata |> Array.map string | |
// Real: 00:00:17.774, CPU: 00:00:17.703, GC gen0: 378, gen1: 61, gen2: 1 | |
let gmap = ref Map.empty<Guid, int> | |
for g in gdata do gmap := gmap.Value.Add(g,42) | |
// Real: 00:00:05.553, CPU: 00:00:05.843, GC gen0: 157, gen1: 35, gen2: 2 | |
let smap = ref Map.empty<string, int> | |
for s in sdata do smap := smap.Value.Add(s, 42) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment