Skip to content

Improved performance of Utf16ValueStringBuilder.AppendFormat on Slow Span Environment#60

Merged
neuecc merged 2 commits intoCysharp:masterfrom
udaken:Improved-performance-of-AppendFormat
Nov 2, 2021
Merged

Improved performance of Utf16ValueStringBuilder.AppendFormat on Slow Span Environment#60
neuecc merged 2 commits intoCysharp:masterfrom
udaken:Improved-performance-of-AppendFormat

Conversation

@udaken
Copy link
Copy Markdown
Contributor

@udaken udaken commented Jun 13, 2021

For environments like Mono and .NET Framework, I reduced the Span used in Utaf16ValueStringBuilder.AppendFormat.

Benchmark on .NET Framework

$ dotnet run -c Release --framework net47
Available Benchmarks:
  #0 AppendPerformance
  #1 FormatBenchmark
...
1
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19043
AMD Ryzen 5 5600X, 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=6.0.100-preview.4.21255.9
  [Host]   : .NET Core 5.0.6 (CoreCLR 5.0.621.22011, CoreFX 5.0.621.22011), X64 RyuJIT  [AttachedDebugger]
  ShortRun : .NET Framework 4.8 (4.8.4341.0), X64 RyuJIT

Job=ShortRun  Runtime=.NET 4.7  IterationCount=1
LaunchCount=1  WarmupCount=1

Before

Method Mean Error Ratio Gen 0 Gen 1 Gen 2 Allocated
StringFormat 155.02 ns NA 1.00 0.1013 - - 169 B
ZStringFormat 149.62 ns NA 0.97 0.0336 - - 56 B
ZStringPreparedFormat 122.82 ns NA 0.79 0.0336 - - 56 B
StringFormatterFormat 81.76 ns NA 0.53 0.0337 - - 56 B

After

Method Mean Error Ratio Gen 0 Gen 1 Gen 2 Allocated
StringFormat 153.41 ns NA 1.00 0.1013 - - 169 B
ZStringFormat 133.61 ns NA 0.87 0.0336 - - 56 B
ZStringPreparedFormat 122.32 ns NA 0.80 0.0336 - - 56 B
StringFormatterFormat 81.04 ns NA 0.53 0.0337 - - 56 B

@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Sep 12, 2021
@neuecc neuecc removed the stale label Sep 13, 2021
@neuecc
Copy link
Copy Markdown
Member

neuecc commented Sep 13, 2021

sorry for the delaying review.
I'll check soon.

@neuecc
Copy link
Copy Markdown
Member

neuecc commented Nov 2, 2021

sorry for the delay to merge, thanks!

@neuecc neuecc merged commit c10c56c into Cysharp:master Nov 2, 2021
@udaken udaken deleted the Improved-performance-of-AppendFormat branch November 16, 2021 02:30
ThangwLee pushed a commit to WolffunGame/ZString that referenced this pull request May 26, 2023
…endFormat

Improved performance of Utf16ValueStringBuilder.AppendFormat on Slow Span Environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants