Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The goal of these refactoring is to unify some of our API and respect the given value of CultureInfo. The implementation is still not perfect, but it's an important first step. Highlights: * Unify ToString APIs All of the ToStr(), ToTimeStr(), ToSizeStr() methods were removed. Initially, they were introduced as hacked shortcuts to formatting purposes, but today they become misleading in some cases. Instead of them, now we always should use ToString(). Where it makes sense, the proper overloads like ToString(CultureInfo, format) are available. * Introduce CultureInfo property in Config Now it's possible to set the CultureInfo, the given value will be used everywhere including exporters (Fix #1295) * Remove MultiEncodingString and Encodings in Configs The original goal of these classes was providing a way to enable Unicode support in exporter (see #487 for details). Unfortunately, it made many APIs overcomplicated because we had to pass Encoding everywhere. If we think carefully, we will understand that the only problem that we actually have relates to the terminal that doesn't support Unicode (in other places, we can use Unicode symbols without any problems). I decided to delete the MultiEncodingString class, use Unicode symbols by default, and patch them only in ConsoleLogger (see AsciiHelper for details). Now, users can turn on Unicode support in console output via [UnicodeConsoleLogger] (see IntroUnicode for details). All other exporters are always able to use Unicode. Some of them may patch Unicode symbols to achieve better portability (e.g., see HtmlExporter.HtmlLoggerWrapper.Escape) * Introduce ILogger.Id and ILogger.Priority These APIs allow overriding existing loggers by custom. For each Id, only the logger with the highest priority will be chosen. With the help of this feature, we can override ConsoleLogger.Ascii with ConsoleLogger.Unicode * Introduce SizeValue This structure is a wrapper for a long value that helps to operate with size values (bytes, kilobytes, etc.) * Rename TimeInterval->TimeValue The original name was confusing because an interval typically has start and end. In our situation, it similar to TimeSpan but has its own features and use cases. I decided to rename it to TimeValue (to make consistent with SizeValue). * Introduce CultureInfo.GetActualListSeparator() TextInfo.ListSeparator shouldn't be used anymore because it returns incorrect value on .NET Core+Unix (see dotnet/runtime#536 for details)
- Loading branch information
1 parent
8486e16
commit f7053ae
Showing
141 changed files
with
1,214 additions
and
905 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Globalization; | ||
using System.Threading; | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Configs; | ||
|
||
namespace BenchmarkDotNet.Samples | ||
{ | ||
[Config(typeof(Config))] | ||
[ShortRunJob] | ||
public class IntroCultureInfo | ||
{ | ||
private class Config : ManualConfig | ||
{ | ||
public Config() | ||
{ | ||
CultureInfo = (CultureInfo) CultureInfo.InvariantCulture.Clone(); | ||
CultureInfo.NumberFormat.NumberDecimalSeparator = "@"; | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void Foo() => Thread.Sleep(100); | ||
} | ||
} |
22 changes: 8 additions & 14 deletions
22
.../BenchmarkDotNet.Samples/IntroEncoding.cs → ...s/BenchmarkDotNet.Samples/IntroUnicode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.