Skip to content

anonymous /gist:4409734
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
F# inline and effects on performance
open System
open System.Collections.Generic
[<Struct>]
type Pair<'a when 'a: equality> =
val v: 'a
val w: 'a
new(x,y)= {v=x;w=y}
let pair x y = new Pair<int>(x,y)
let inline Eq_cmp<'a when 'a: equality> = {
new IEqualityComparer<Pair<'a>> with
member x.Equals(a, b) =
(a.v = b.v) && (a.w = b.w)
member x.GetHashCode(y) =
let mutable h = 17 in
h <- y.v.GetHashCode()+(h*23);
h <- y.w.GetHashCode()+(h*23);
h
}
let perf_run i =
let c = Eq_cmp<int> in
let map = new Dictionary<_ , _>(10000000,c)
for j=0 to i do
map.Add((pair j (j*23^^^i)), i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.