| 61 | } |
| 62 | |
| 63 | void ScopedLoggingTimer::StopAndLog() { |
| 64 | if (enabled_) { |
| 65 | uint64 end_micros = tensorflow::Env::Default()->NowMicros(); |
| 66 | double secs = (end_micros - start_micros_) / 1000000.0; |
| 67 | |
| 68 | TimerStats& stats = *timer_stats_; |
| 69 | tensorflow::mutex_lock lock(stats.stats_mutex); |
| 70 | stats.cumulative_secs += secs; |
| 71 | if (secs > stats.max_secs) { |
| 72 | stats.max_secs = secs; |
| 73 | } |
| 74 | stats.times_called++; |
| 75 | |
| 76 | LOG(INFO).AtLocation(file_, line_) |
| 77 | << label_ |
| 78 | << " time: " << tensorflow::strings::HumanReadableElapsedTime(secs) |
| 79 | << " (cumulative: " |
| 80 | << tensorflow::strings::HumanReadableElapsedTime(stats.cumulative_secs) |
| 81 | << ", max: " |
| 82 | << tensorflow::strings::HumanReadableElapsedTime(stats.max_secs) |
| 83 | << ", #called: " << stats.times_called << ")"; |
| 84 | enabled_ = false; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | ScopedLoggingTimer::~ScopedLoggingTimer() { StopAndLog(); } |
| 89 |
nothing calls this directly
no test coverage detected