MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / setColorForBytesBasedMetricsProgress

Function setColorForBytesBasedMetricsProgress

src/Client/ProgressTable.cpp:108–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108std::string_view setColorForBytesBasedMetricsProgress(double progress)
109{
110 constexpr std::array<std::string_view, 7> colors = {
111 "\033[38;5;236m", /// Dark Grey
112 "\033[38;5;250m", /// Light Grey
113 "\033[38;5;34m", /// Green
114 "\033[38;5;226m", /// Yellow
115 "\033[38;5;208m", /// Orange
116 "\033[1;33m", /// Bold
117 "\033[38;5;160m", /// Red: corresponds to >= 1T/s. Not a practical scenario.
118 };
119
120 /// Bytes.
121 constexpr std::array<uint64_t, 6> thresholds = {
122 1LL << 20,
123 100LL << 20,
124 1'000LL << 20,
125 10'000LL << 20,
126 100'000LL << 20,
127 1'000'000LL << 20,
128 };
129
130 auto dist = std::upper_bound(thresholds.begin(), thresholds.end(), progress) - thresholds.begin();
131 return colors[dist];
132}
133
134std::string_view setColorForTimeBasedMetricsProgress(ProfileEvents::ValueType value_type, double progress)
135{

Callers 1

writeTableMethod · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected