| 132 | } |
| 133 | |
| 134 | std::string_view setColorForTimeBasedMetricsProgress(ProfileEvents::ValueType value_type, double progress) |
| 135 | { |
| 136 | /// Time units in a second. |
| 137 | auto units = [](ProfileEvents::ValueType t) -> double |
| 138 | { |
| 139 | switch (t) |
| 140 | { |
| 141 | case ProfileEvents::ValueType::Milliseconds: |
| 142 | return 1e3; |
| 143 | case ProfileEvents::ValueType::Microseconds: |
| 144 | return 1e6; |
| 145 | case ProfileEvents::ValueType::Nanoseconds: |
| 146 | return 1e9; |
| 147 | default: |
| 148 | throw Exception(ErrorCodes::LOGICAL_ERROR, "Wrong value type, expecting time units"); |
| 149 | } |
| 150 | }(value_type); |
| 151 | |
| 152 | constexpr std::array<std::string_view, 5> colors = { |
| 153 | "\033[38;5;236m", /// Dark Grey |
| 154 | "\033[38;5;250m", /// Light Grey |
| 155 | "\033[38;5;34m", /// Green |
| 156 | "\033[38;5;226m", /// Yellow |
| 157 | "\033[1;33m" /// Bold |
| 158 | }; |
| 159 | |
| 160 | const std::array<double, 4> thresholds = {0.001 * units, 0.01 * units, 0.1 * units, 1.0 * units}; |
| 161 | |
| 162 | auto dist = std::upper_bound(thresholds.begin(), thresholds.end(), progress) - thresholds.begin(); |
| 163 | return colors[dist]; |
| 164 | } |
| 165 | |
| 166 | std::string_view setColorForDocumentation() |
| 167 | { |
no test coverage detected