Is there anything I can do to make f# code compile faster apart from (or better yet instead of) running ngen?
And what is approximate benchmark "hello world" compilation time (or better said compiler startup time+compilation time) for say pentium 4 machine?
Edit There are nuances as it turns out:)
So first, can anyone explain what is start-up time of compiler? And why is it slow. Also links to information on the whole f# compilation process would be appreciated.
Context: f# compiler is repeatedly invoked on small snippets of code through
using (CodeDomProvider provider = new Microsoft.FSharp.Compiler.CodeDom.FSharpCodeProvider())
{
//start time
cr = provider.CompileAssemblyFromSource(cp, new string[] { data.Program });
//end time
}
The time difference is ~6 sec. So the question basically is what can be done, apart from ngen? You can see for yourself here:rundotnet
This takes 0.9s on my computer (AMD Athlon 64 X2 4600):
#r "FSharp.Compiler.CodeDom"
open System.Reflection
open System.CodeDom.Compiler
open Microsoft.FSharp.Compiler.CodeDom
let comp() =
use provider = new FSharpCodeProvider()
let code = "module pp\n printfn \"Hello world\""
let cp = new CompilerParameters()
cp.GenerateInMemory <- true
provider.CompileAssemblyFromSource(cp, [|code|]) |> ignore
#time
comp()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With