New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add System.Text.CompositeFormat #80753
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Benchmark via the higher-level LoggerMessage which this PR also updates to use this: using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Microsoft.Extensions.Logging;
using System;
[MemoryDiagnoser]
public partial class Program
{
static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
private Action<ILogger, int, Exception> _message = LoggerMessage.Define<int>(LogLevel.Critical, 1, "The value is {0}.");
private ILogger _logger = new MyLogger();
[Benchmark]
public void Format() => _message(_logger, 42, null);
sealed class MyLogger : ILogger
{
public IDisposable BeginScope<TState>(TState state) => null;
public bool IsEnabled(LogLevel logLevel) => true;
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) => formatter(state, exception);
}
}
|
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsFixes #50330
|
src/libraries/System.Private.CoreLib/src/System/Text/CompositeFormat.cs
Outdated
Show resolved
Hide resolved
...braries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ComInterop/IDispatchComObject.cs
Show resolved
Hide resolved
|
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeExceptionHandlingClause.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs
Outdated
Show resolved
Hide resolved
...ies/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs
Show resolved
Hide resolved
/benchmark |
/benchmark test test runtime |
/benchmark help |
Crank Pull Request Bot
Benchmarks:
Profiles:
Components:
Arguments: any additional arguments to pass through to crank, e.g. |
/benchmark microbenchmarks --variable filter=Formatting aspnet-perf-win runtime |
/benchmark microbenchmarks aspnet-perf-win runtime --variable filter=Formatting |
Benchmark started for microbenchmarks on aspnet-perf-win with runtime and arguments |
An error occured, please check the logs |
/benchmark microbenchmarks aspnet-perf-win runtime --variable filter=Formatting |
Benchmark started for microbenchmarks on aspnet-perf-win with runtime and arguments |
microbenchmarks - aspnet-perf-win
| benchmark | mean (microbenchmarks.base) | mean (microbenchmarks.pr) | ratio | allocated (microbenchmarks.base) | allocated (microbenchmarks.pr) | ratio |
| ------------------------------------------------------------------------------------------------ | --------------------------- | ------------------------- | ----- | -------------------------------- | ------------------------------ | ----- |
| Microsoft.Extensions.Logging.Formatting.NoArguments | 21.79 ns | 21.54 ns | 0.99 | 0 B | 0 B | |
| Microsoft.Extensions.Logging.Formatting.TwoArguments | 101.75 ns | 97.92 ns | 0.96 | 80 B | 80 B | 1.00 |
| Microsoft.Extensions.Logging.FormattingOverhead.FourArguments_DefineMessage | 161.7 ns | 161.6 ns | 1.00 | 176 B | 176 B | 1.00 |
| Microsoft.Extensions.Logging.FormattingOverhead.FourArguments_EnumerableArgument | 585.0 ns | 568.1 ns | 0.97 | 656 B | 656 B | 1.00 |
| Microsoft.Extensions.Logging.FormattingOverhead.NoArguments | 19.67 ns | 19.57 ns | 1.00 | 0 B | 0 B | |
| Microsoft.Extensions.Logging.FormattingOverhead.TwoArguments | 116.9 ns | 118.6 ns | 1.01 | 120 B | 120 B | 1.00 |
| Microsoft.Extensions.Logging.FormattingOverhead.TwoArguments_DefineMessage | 97.29 ns | 97.83 ns | 1.01 | 80 B | 80 B | 1.00 |
| PerfLabTests.LowLevelPerf.IntegerFormatting | 775.6 μs | 753.1 μs | 0.97 | 4.58 MB | 4.58 MB | 1.00 |
| System.Perf_Convert.ToBase64CharArray(binaryDataSize: 1024, formattingOptions: InsertLineBreaks) | 997.4 ns | 992.8 ns | 1.00 | 0 B | 0 B | |
| System.Perf_Convert.ToBase64CharArray(binaryDataSize: 1024, formattingOptions: None) | 94.64 ns | 94.82 ns | 1.00 | 0 B | 0 B | |
| System.Perf_Convert.ToBase64String(formattingOptions: InsertLineBreaks) | 1.1 μs | 1.1 μs | 0.99 | 2.77 KB | 2.77 KB | 1.00 |
| System.Perf_Convert.ToBase64String(formattingOptions: None) | 180.3 ns | 179.5 ns | 1.00 | 2.7 KB | 2.7 KB | 1.00 | |
/benchmark microbenchmarks aspnet-citrine-win-ampere runtime --variable filter=Formatting |
Benchmark started for microbenchmarks on aspnet-citrine-win-ampere with runtime and arguments |
microbenchmarks - aspnet-citrine-win-ampere
| benchmark | mean (microbenchmarks.base) | mean (microbenchmarks.pr) | ratio | allocated (microbenchmarks.base) | allocated (microbenchmarks.pr) | ratio |
| ------------------------------------------------------------------------------------------------ | --------------------------- | ------------------------- | ----- | -------------------------------- | ------------------------------ | ----- |
| Microsoft.Extensions.Logging.Formatting.NoArguments | 64.11 ns | 65.49 ns | 1.02 | 0 B | 0 B | |
| Microsoft.Extensions.Logging.Formatting.TwoArguments | 260.6 ns | 283.0 ns | 1.09 | 80 B | 80 B | 1.00 |
| Microsoft.Extensions.Logging.FormattingOverhead.FourArguments_DefineMessage | 568.1 ns | 512.1 ns | 0.90 | 176 B | 176 B | 1.00 |
| Microsoft.Extensions.Logging.FormattingOverhead.FourArguments_EnumerableArgument | 1.6 μs | 1.5 μs | 0.91 | 656 B | 656 B | 1.00 |
| Microsoft.Extensions.Logging.FormattingOverhead.NoArguments | 63.82 ns | 57.47 ns | 0.90 | 0 B | 0 B | |
| Microsoft.Extensions.Logging.FormattingOverhead.TwoArguments | 395.3 ns | 402.2 ns | 1.02 | 120 B | 120 B | 1.00 |
| Microsoft.Extensions.Logging.FormattingOverhead.TwoArguments_DefineMessage | 301.2 ns | 307.0 ns | 1.02 | 80 B | 80 B | 1.00 |
| PerfLabTests.LowLevelPerf.IntegerFormatting | 2.2 ms | 2.4 ms | 1.12 | 4.58 MB | 4.58 MB | 1.00 |
| System.Perf_Convert.ToBase64CharArray(binaryDataSize: 1024, formattingOptions: InsertLineBreaks) | 2.0 μs | 2.0 μs | 1.02 | 0 B | 0 B | |
| System.Perf_Convert.ToBase64CharArray(binaryDataSize: 1024, formattingOptions: None) | 965.3 ns | 1,006.8 ns | 1.04 | 0 B | 0 B | |
| System.Perf_Convert.ToBase64String(formattingOptions: InsertLineBreaks) | 2.2 μs | 2.3 μs | 1.06 | 2.77 KB | 2.77 KB | 1.00 |
| System.Perf_Convert.ToBase64String(formattingOptions: None) | 1.1 μs | 1.2 μs | 1.03 | 2.7 KB | 2.7 KB | 1.00 | |
b6f248f
to
83dd002
Compare
* Add System.Text.CompositeFormat * Conditionalize a test and remove extra const * Address PR feedback
Fixes #50330