BenchmarkDotNet
BenchmarkDotNet copied to clipboard
Improve contrast in console (dark text on black console)
When I run BenchmarkDotNet.Samples.FSharp, here is what the console looks like.

The text is a dark color on a black background. I am having difficulty seeing the text.
Can this contrast be improved?
Hello @bender2k14
Can this contrast be improved?
Yes, but it would require your contribution.
The colors are defined here Please feel free to experiment with them and send a PR.
Thanks, Adam
Hello @adamsitnik, thanks for your response.
If you would prefer to reinvent logging (instead taking on dependency for logging), then I recommend copying how Serilog.Sinks.Console does it. Specifically, the coloring that you are currently using is fine but only apply it to the log type (which implies that it is also displayed). The primary text would be white (or off-white if someone wants to optimize it) on a black background, which is a high contract for easy reading.
What do you think?
Do you mean using the same colors as Serilog?

I am fine with that. @AndreyAkinshin what do you think?
@adamsitnik so, do I understand correctly that we are going to replace
{ LogKind.Help, ConsoleColor.DarkGreen },
with
{ LogKind.Help, ConsoleColor.White },
?
@AndreyAkinshin yes, but we might also want to set bg color to red for error and yellow text color for warning
Do you mean using the same colors as Serilog?
I don't care about the exact colors used. I am suggesting that the text to be logged should be white regardless of the log kind so that the contrast with the black background is high. That will make it easier to read. Instead of coloring the text to be logged, I am suggesting that an abbreviation of the log kind could be colored using your existing color scheme.
do I understand correctly that we are going to replace...
No. Sorry that I have been unclear. I created PR #1404 that makes the kind of change that I am talking about. It also includes a screenshot of the new behavior.
I've marked the issue as up-for-grabs. Whoever is willing to work on this, please experiment with the color scheme that is defined here; https://github.com/dotnet/BenchmarkDotNet/blob/3223c94a92050147a02482a3810860703f0c5171/src/BenchmarkDotNet/Loggers/ConsoleLogger.cs#L64-L75
and find a better one ;)
It seems that creating a palette based on the 16 terminal colors that look nice in all possible color themes in all possible terminals is an unsolvable task. Each terminal overrides the standard colors; and for the majority of colors, there is a terminal color theme in which the selected color is not so readable.
If we want to create a palette that is readable in all the terminals, we should go beyond the standard 16 colors and use at least 256 colors if it's an available option. Here are some of my thoughts about the implementation:
- 16-color mode should still be supported since not all the terminals support 256 colors. Only if 256 colors are supported, we should switch to the extended color palette.
- In the main BenchmarkDotNet package, we try to avoid any non-essential NuGet dependencies. Therefore, we don't want to reference any packages with advanced terminal color support.
- It seems that it's not so hard to implement 256-color support from scratch. As a source of inspiration, existing projects like Colorful.Console or Tamar.ANSITerm can be used. We are not interested in any advanced features; only extended color support is needed.