| 194 | } |
| 195 | |
| 196 | ProfilerSession::ProfilerSession() |
| 197 | : active_(!session_active.exchange(true)), |
| 198 | start_time_micros_(Env::Default()->NowNanos() / EnvTime::kMicrosToNanos) { |
| 199 | if (!active_) { |
| 200 | status_ = tensorflow::Status(error::UNAVAILABLE, |
| 201 | "Another profiler session is active."); |
| 202 | return; |
| 203 | } |
| 204 | |
| 205 | LOG(INFO) << "Profiler session started."; |
| 206 | |
| 207 | CreateProfilers(&profilers_); |
| 208 | status_ = Status::OK(); |
| 209 | |
| 210 | for (auto& profiler : profilers_) { |
| 211 | auto start_status = profiler->Start(); |
| 212 | if (!start_status.ok()) { |
| 213 | LOG(WARNING) << "Encountered error while starting profiler: " |
| 214 | << start_status.ToString(); |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | ProfilerSession::~ProfilerSession() { |
| 220 | for (auto& profiler : profilers_) { |