Also, you can just mark it inline with the inline keyword. Then the F# compiler will do it for you. Performance is a tricky thing, especially on a platform like this where you have to consider F# -> IL -> Native and then all the native issues.

However, sometimes if youre not doing much work, and a call is actually measureable overhead, F# inling can make a _huge_ difference. As always, measure measure measure.

By on 6/3/2009 1:05 PM ()

I don't think it will be inlined; it is easy to verify by inspecting the IL or using .Net Reflector on the generated assembly compiled in 'Release' mode.

In this case, the overhead will be very small relative to the O(N^2) performance hole you have in this snippet using @. (Better to cons the list together backwards and then call List.rev on the result at the end - O(N).)

By on 6/3/2009 9:46 AM ()

i'll take a look, but ... i'm doing "list of 1 element" @ "list of n". that shouldn't be o(n) - if i had it reversed - "list of n" @ "list of 1", then yes.

but you're right cons would be cheaper here because i wouldn't be creating a list of one just to dispose of it in a minute.

thanks.

By on 6/3/2009 11:09 AM ()

You're right, I didn't look closely enough the first time.

By on 6/3/2009 11:57 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper