简体   繁体   中英

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 some 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM