Question

I recently noticed that F# Interactive is much faster than the compiled version (in either Release or Debug mode). Here is an example:

let rec fib n = if n < 3 then 1 else fib (n-1) + fib (n-2)

[<EntryPoint>]
let rec main argv = 
    let w = System.Diagnostics.Stopwatch()
    w.Start()
    fib 45
    w.Stop()
    printfn "%d" w.ElapsedMilliseconds
    System.Console.ReadLine()
    0

When compiled in release mode then run this outputs "12784", when run in F# Interactive it outputs "4986". I am running it in Interactive mode using "main [||];;".

Something weird is definitely going on, but I have no idea what!

EDIT [Specs]: F# 3.0 for .NET 4. The optimize code and generate tail call flags are set and I am compiling for x86. I am running this on an i7 950. I am using visual studio 2012.

Était-ce utile?

La solution

Ran executable outside of VS2012 as suggested by pad, then changed to .NET 4.5. This equalized the run times.

Autres conseils

Please see my answer : What makes this F# so slow in VS2012?

you have to add Fsharp.core.dll file to your exe file to make it load faster.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top