Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to optimize F# programs generally [closed]

I have an interpreter for a lisp-style language in F#, and have just gotten into the optimization phase. Simple tests of the evaluator reveal that I need to optimize it in an extreme manner. However, I don't have a general background in F# performance or optimization.

Are there any good general knowledge resources for F# program optimization? Particularly useful are tips of keeping cache coherency and surprising primitive performance issues. A cursory search hasn't revealed much on the internet.

Thank you!

like image 760
Bryan Edds Avatar asked Feb 12 '12 21:02

Bryan Edds


People also ask

How do I optimize a function in R?

optimize() or optimise() function in R Language is used to search the interval from lower to upper for a minimum or maximum of the function f with respect to its first argument. Parameters: f: the function to be optimized.


1 Answers

Performance optimization tricks are all myths. As @svick said, it's no better way than profiling your program, identifying hot spots and optimizing them using concrete benchmarks.

Since you asked, here is some information floating around:

  • A bunch of good answers about F# performance: C# / F# Performance comparison
  • Using inline for performance optimization: Use of `inline` in F#
  • Using structs instead of records for better performance: http://theburningmonk.com/2011/10/fsharp-performance-test-structs-vs-records/
  • Array-oriented programming for performance-critical code: http://sharp-gamedev.blogspot.com/2010/03/thoughts-about-f-and-xbox-games.html
  • Concrete case studies of performance optimization:

    FSharp runs my algorithm slower than Python

    F# seems slower than other languages... what can I do to speed it up?

like image 106
pad Avatar answered Oct 11 '22 00:10

pad