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

Function setColorForProgress

src/Client/ProgressTable.cpp:83–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81
82
83std::string_view setColorForProgress(double progress, double max_progress)
84{
85 constexpr std::array<std::string_view, 5> colors = {
86 "\033[38;5;236m", /// Dark Grey
87 "\033[38;5;250m", /// Light Grey
88 "\033[38;5;34m", /// Green
89 "\033[38;5;226m", /// Yellow
90 "\033[1;33m", /// Bold
91 };
92
93 constexpr std::array<double, 4> fractions = {
94 0.05,
95 0.20,
96 0.80,
97 0.95,
98 };
99
100 if (max_progress == 0)
101 return colors.front();
102
103 auto fraction = progress / max_progress;
104 auto dist = std::upper_bound(fractions.begin(), fractions.end(), fraction) - fractions.begin();
105 return colors[dist];
106}
107
108std::string_view setColorForBytesBasedMetricsProgress(double progress)
109{

Callers 1

writeTableMethod · 0.85

Calls 3

frontMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected