@@ -77,17 +77,9 @@ ostream& operator<<(ostream& os, Performance const& p) {
7777WorkerPerformance::WorkerPerformance ()
7878 : receive_time(util::TimeUtils::now()), start_time(0 ), finish_time(0 ) {}
7979
80- uint64_t WorkerPerformance::setUpdateStart () {
81- uint64_t const t = start_time;
82- start_time = util::TimeUtils::now ();
83- return t;
84- }
80+ uint64_t WorkerPerformance::setUpdateStart () { return start_time.exchange (util::TimeUtils::now ()); }
8581
86- uint64_t WorkerPerformance::setUpdateFinish () {
87- uint64_t const t = finish_time;
88- finish_time = util::TimeUtils::now ();
89- return t;
90- }
82+ uint64_t WorkerPerformance::setUpdateFinish () { return finish_time.exchange (util::TimeUtils::now ()); }
9183
9284unique_ptr<ProtocolPerformance> WorkerPerformance::info () const {
9385 auto ptr = make_unique<ProtocolPerformance>();
@@ -97,6 +89,12 @@ unique_ptr<ProtocolPerformance> WorkerPerformance::info() const {
9789 return ptr;
9890}
9991
92+ json WorkerPerformance::toJson () const {
93+ return json::object ({{" receive_time" , receive_time.load ()},
94+ {" start_time" , start_time.load ()},
95+ {" finish_time" , finish_time.load ()}});
96+ }
97+
10098ostream& operator <<(ostream& os, WorkerPerformance const & p) {
10199 os << " WorkerPerformance "
102100 << " receive:" << p.receive_time << " start:" << p.start_time << " finish:" << p.finish_time
0 commit comments