Skip to content

Instantly share code, notes, and snippets.

@nightroman
Last active March 12, 2019 02:32
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 nightroman/19b9e185f6571b6bbaa8c08fc8d48fac to your computer and use it in GitHub Desktop.
Save nightroman/19b9e185f6571b6bbaa8c08fc8d48fac to your computer and use it in GitHub Desktop.
// F# call via interface vs. record
type IFace =
abstract Test: int -> string -> unit
type IRecord = {
Test: int -> string -> unit
}
let myTest i s =
()
let myFace = { new IFace with
member __.Test i s = myTest i s
}
let myRecord = {
Test = myTest
}
let profile fn =
let sw = System.Diagnostics.Stopwatch.StartNew ()
for i in 1 .. 100000000 do
fn ()
printfn "%A" sw.Elapsed
printfn "timing..."
profile (fun () -> myFace.Test 1 "1")
profile (fun () -> myRecord.Test 1 "1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment