开发者

Compiling an F# quotation: performance?

I have an F# quotation that I manipulate (I add object pools everywhere to recycle short lived objects that get created and deleted very often). I would like to run the resulting quotation; for now I have used the F# PowerPack which offers methods to convert a quotation to an expression tree and the to a delegate, which I run. Having no access to the generated code, I was wondering:

-what is the performance of the compiled code? Is there s开发者_开发问答ome layer of reflection that is not removed or is it a true compilation?

  • can I see the generated code and use .Net Reflector on it?

thanks :)


Last I looked, the performance was absolutely awful, around 50× slower than F# and even slower than a naive interpreter.

Frankly, I don't understand why they didn't just expose the F# compiler itself as a run-time service (and FSI). F# would have much better tooling now if they had done...

EDIT: I benchmarked quotations running a fibonacci function last night and it was actually 700× slower!!!


This is a bit of a non-answer, but when it comes to performance only you can know what your true performance requirements are. Do you have a particular target running time in mind? Have you tried running the compiled quotation? Was it fast enough? Did you compare it to a natively written F# function?

Regarding your last question, I don't know of any easy way to view an in-memory assembly in Reflector. However, the F# PowerPack's source is available, so you can read it to see exactly how the quotations are compiled.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜