Last active
March 12, 2019 02:32
-
-
Save nightroman/19b9e185f6571b6bbaa8c08fc8d48fac to your computer and use it in GitHub Desktop.
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
// 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