Why is printf in F# so slow?

前端 未结 4 2026
悲&欢浪女
悲&欢浪女 2020-12-14 02:50

I\'ve just been really surprised by how slow printf from F# is. I have a number of C# programs that process large data files and write out a number of CSV files. I originall

4条回答
  •  情歌与酒
    2020-12-14 03:43

    Now that F# 3.1 has been preview released, the performance of printf is claimed to have increased by 40x. You might want to have a look at this:

    F# 3.1 Compiler/Library Additions

    Printf performance

    The F# 3.1 core library sees improved performance of the printf family of functions for type-safe formatting. For example, printing using the following format string now runs up to 40x faster (though your exact mileage may vary):

    sprintf "%d: %d, %x %X %d %d %s" No changes in your code are needed to take advantage of this improved performance, though you do need to be using the F# 3.1 FSharp.Core.dll runtime component.

提交回复
热议问题