Uh oh!
There was an error while loading. Please reload this page.
Use String.concat to concatenate command line arguments - #9297
Conversation
d813884 to
ac4a13bCompareKevinRansom
commented
May 26, 2020
@saul, I think the test failed because it expected an additional newline. |
cartermp
commented
May 26, 2020
I'm not sure how to read that chart, but isn't this saying that the 4.3s is coming from |
Yes all of the Seq.fold slowness is due to String.Concat (the BCL method). I replaced it with String.concat (the F# wrapper that passes to String.Join) as that uses StringBuilder under the hood. Sorry if my description was confusing! |
cartermp
commented
May 26, 2020
Thanks, looks good. I did a quick benchmark and it likely corroborates your own findings 🙂 // Learn more about F# at http://docs.microsoft.com/dotnet/fsharpopenSystemopenBenchmarkDotNet.AttributesopenBenchmarkDotNet.Running[<MemoryDiagnoser>]typeConcatBench()=letstrings=[for x in0..100-> sprintf "--commandlinearg:%d" x ][<Benchmark(Baseline=true)>]member_.SeqFold()=
strings
|> Seq.fold (fun acc f -> acc + f + Environment.NewLine)""|> ignore
[<Benchmark>]member_.FSharpCoreStringConcat()=
strings
|> String.concat Environment.NewLine
|> ignore
[<EntryPoint>]letmain argv =letsummary= BenchmarkRunner.Run<ConcatBench>()
printfn "%A" summary
0// return an integer exit code.NET Framework:
On .NET 5:
|
saul
commented
May 26, 2020
Really appreciate the quick turnaround, thanks both :) |
* Use `String.concat` to concatenate command line arguments * Fix newline at end of cmd Co-authored-by: Kevin Ransom (msft) <codecutter.fsharp@hotmail.com>
While profiling design time builds I noticed that the Seq.fold here is responsible for most of the Fsc task's run time: