|
| 1 | +/* |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +#include "velox/exec/OperatorStats.h" |
| 18 | +#include <fmt/format.h> |
| 19 | +#include <sstream> |
| 20 | + |
| 21 | +namespace facebook::velox::exec { |
| 22 | + |
| 23 | +std::string OperatorStats::toString() const { |
| 24 | + std::stringstream out; |
| 25 | + |
| 26 | + out << "[OperatorStats][" << operatorId << "] " << operatorType << " [" |
| 27 | + << planNodeId << "]"; |
| 28 | + |
| 29 | + out << "\n input: " << inputPositions << " rows (" << inputBytes |
| 30 | + << " bytes, " << inputVectors << " vectors)"; |
| 31 | + out << "\n output: " << outputPositions << " rows (" << outputBytes |
| 32 | + << " bytes, " << outputVectors << " vectors)"; |
| 33 | + |
| 34 | + if (numSplits > 0) { |
| 35 | + out << "\n splits: " << numSplits; |
| 36 | + } |
| 37 | + |
| 38 | + if (spilledBytes > 0) { |
| 39 | + out << "\n spilled: " << spilledBytes << " bytes (" << spilledRows |
| 40 | + << " rows, " << spilledPartitions << " partitions)"; |
| 41 | + } |
| 42 | + |
| 43 | + if (blockedWallNanos > 0) { |
| 44 | + out << "\n blockedWallMs: " |
| 45 | + << fmt::format("{:.2f}ms", blockedWallNanos / 1e6); |
| 46 | + } |
| 47 | + |
| 48 | + out << "\n runtimeStats: {"; |
| 49 | + for (const auto& [name, metric] : runtimeStats) { |
| 50 | + out << "\n " << name << ":" << metric.sum << ","; |
| 51 | + } |
| 52 | + out << "\n }"; |
| 53 | + |
| 54 | + return out.str(); |
| 55 | +} |
| 56 | + |
| 57 | +} // namespace facebook::velox::exec |
0 commit comments