相关疑难解决方法(0)

F#string.Format

我正在写我的第一个F#库

我试图使用string.Format它并抱怨没有这样的功能.

它不可用或我做错了什么?

f#

40
推荐指数
1
解决办法
2万
查看次数

为什么F#中的printf这么慢?

我对F#的printf有多慢感到惊讶.我有许多C#程序处理大型数据文件并写出许多CSV文件.我最初的fprintf writer "%s,%d,%f,%f,%f,%s"想法是认为这将是简单而合理有效的.

然而,过了一段时间我有点厌倦了等待文件处理.(我有4GB的XML文件可以通过它们写出来.).

当我通过分析器运行我的应用程序时,我惊讶地发现printf是一种非常慢的方法.

我将代码更改为不使用printf,现在性能要好得多.Printf性能破坏了我的整体应用程序性能.

举个例子,我原来的代码是:

fprintf sectorWriter "\"%s\",%f,%f,%d,%d,\"%s\",\"%s\",\"%s\",%d,%d,%d,%d,\"%s\",%d,%d,%d,%d,%s,%d"
    sector.Label sector.Longitude sector.Latitude sector.RNCId sector.CellId
    siteName sector.Switch sector.Technology (int sector.Azimuth) sector.PrimaryScramblingCode
    (int sector.FrequencyBand) (int sector.Height) sector.PatternName (int sector.Beamwidth) 
    (int sector.ElectricalTilt) (int sector.MechanicalTilt) (int (sector.ElectricalTilt + sector.MechanicalTilt))
    sector.SectorType (int sector.Radius)
Run Code Online (Sandbox Code Playgroud)

我已将其改为以下内容

seq {
    yield sector.Label; yield string sector.Longitude; yield string sector.Latitude; yield string sector.RNCId; yield string sector.CellId; 
    yield siteName; yield sector.Switch; yield sector.Technology; yield string (int sector.Azimuth); yield string sector.PrimaryScramblingCode;
    yield string (int sector.FrequencyBand); yield string (int sector.Height); yield …
Run Code Online (Sandbox Code Playgroud)

performance f#

17
推荐指数
4
解决办法
1427
查看次数

标签 统计

f# ×2

performance ×1