diff options
author | Shashi Shekhar <shashishekhar@google.com> | 2018-06-04 15:00:11 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-06-04 15:02:44 -0700 |
commit | e2d300823f410823b1b5fee4e5159a754247e219 (patch) | |
tree | c7f31757883d8689f0a24a58e8d64e3b42f36058 /tensorflow/core/util/stats_calculator.cc | |
parent | 142ccf3666e07d011aa83fdd6be8c17f721fbc99 (diff) |
Move benchmarking code to a new directory and add some documentation.
PiperOrigin-RevId: 199200246
Diffstat (limited to 'tensorflow/core/util/stats_calculator.cc')
-rw-r--r-- | tensorflow/core/util/stats_calculator.cc | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/tensorflow/core/util/stats_calculator.cc b/tensorflow/core/util/stats_calculator.cc index 20353ec76e..c4befbdb84 100644 --- a/tensorflow/core/util/stats_calculator.cc +++ b/tensorflow/core/util/stats_calculator.cc @@ -21,8 +21,6 @@ limitations under the License. #include <sstream> #include <string> -#include "tensorflow/core/platform/logging.h" - namespace tensorflow { StatsCalculator::StatsCalculator(const StatSummarizerOptions& options) @@ -93,7 +91,7 @@ std::string StatsCalculator::ColumnString(const Detail& detail, void StatsCalculator::OrderNodesByMetric( SortingMetric metric, std::vector<const Detail*>* details) const { - std::priority_queue<std::pair<string, const Detail*>> sorted_list; + std::priority_queue<std::pair<std::string, const Detail*>> sorted_list; const int num_nodes = details_.size(); for (const auto& det : details_) { @@ -142,7 +140,7 @@ void StatsCalculator::ComputeStatsByType( int64_t run_count = run_total_us_.count(); for (const auto& det : details_) { - const string node_name = det.first; + const std::string node_name = det.first; const Detail& detail = det.second; int64_t curr_time_val = @@ -151,7 +149,7 @@ void StatsCalculator::ComputeStatsByType( int64_t curr_memory_val = detail.mem_used.newest(); - const string& node_type = detail.type; + const std::string& node_type = detail.type; (*node_type_map_count)[node_type] += 1; (*node_type_map_time)[node_type] += curr_time_val; @@ -163,12 +161,12 @@ void StatsCalculator::ComputeStatsByType( std::string StatsCalculator::GetStatsByNodeType() const { std::stringstream stream; + stream << "Number of nodes executed: " << details_.size() << std::endl; + stream << "============================== Summary by node type " "==============================" << std::endl; - LOG(INFO) << "Number of nodes executed: " << details_.size(); - std::map<std::string, int64_t> node_type_map_count; std::map<std::string, int64_t> node_type_map_time; std::map<std::string, int64_t> node_type_map_memory; @@ -180,11 +178,12 @@ std::string StatsCalculator::GetStatsByNodeType() const { &accumulated_us); // Sort them. - std::priority_queue<std::pair<int64_t, std::pair<string, int64_t>>> timings; + std::priority_queue<std::pair<int64_t, std::pair<std::string, int64_t>>> + timings; for (const auto& node_type : node_type_map_time) { const int64_t mem_used = node_type_map_memory[node_type.first]; timings.emplace(node_type.second, - std::pair<string, int64_t>(node_type.first, mem_used)); + std::pair<std::string, int64_t>(node_type.first, mem_used)); } InitField(stream, 24) << "[Node type]"; @@ -201,7 +200,7 @@ std::string StatsCalculator::GetStatsByNodeType() const { auto entry = timings.top(); timings.pop(); - const string node_type = entry.second.first; + const std::string node_type = entry.second.first; const float memory = entry.second.second / 1000.0f; const int64_t node_type_total_us = entry.first; @@ -273,14 +272,6 @@ std::string StatsCalculator::GetOutputString() const { return stream.str(); } -void StatsCalculator::PrintStepStats() const { - string output = GetOutputString(); - std::istringstream iss(output); - for (std::string line; std::getline(iss, line);) { - LOG(INFO) << line; - } -} - void StatsCalculator::UpdateDetails( const std::map<std::string, Detail>& details) { details_.insert(details.begin(), details.end()); |