blob: 56623e992776ea2f1016d21603abaf1e821ddf09 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "operation_tracker.h"
#include <yt/cpp/mapreduce/interface/config.h>
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
void TOperationExecutionTimeTracker::Start(const TOperationId& operationId) {
with_lock(Lock_) {
StartTimes_[operationId] = TInstant::Now();
}
}
TMaybe<TDuration> TOperationExecutionTimeTracker::Finish(const TOperationId& operationId) {
TDuration duration;
with_lock(Lock_) {
auto i = StartTimes_.find(operationId);
if (i == StartTimes_.end()) {
return Nothing();
}
duration = TInstant::Now() - i->second;
StartTimes_.erase(i);
}
return duration;
}
TOperationExecutionTimeTracker* TOperationExecutionTimeTracker::Get() {
return Singleton<TOperationExecutionTimeTracker>();
}
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
|