F# が次のコードを最適化するほど賢くない理由はありますか? fast = 880
とslow = 8090
。
type Data = { fn: int * int -> int }
let fn (x, y) = x + y
let data = { fn = fn }
let mutable a = 0
let s = System.Diagnostics.Stopwatch()
s.Start()
for i in 0 .. 1000000000 do
a <- fn(i, i)
printfn "fast = %d" s.ElapsedMilliseconds
s.Restart()
for i in 0 .. 1000000000 do
a <- data.fn(i, i)
printfn "slow = %d" s.ElapsedMilliseconds