MCPcopy Create free account
hub / github.com/ChunelFeng/CGraph / MyTimerAspect

Class MyTimerAspect

tutorial/MyGAspect/MyTimerAspect.h:16–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include "CGraph.h"
15
16class MyTimerAspect : public CGraph::GAspect {
17public:
18 /**
19 * 实现计时切面逻辑,记录 run() 方法的执行耗时信息
20 */
21 CStatus beginRun() override {
22 start_ts_ = std::chrono::steady_clock::now();
23 return CStatus();
24 }
25
26 CVoid finishRun(const CStatus& curStatus) override {
27 std::chrono::duration<double, std::milli> span = std::chrono::steady_clock::now() - start_ts_;
28 CGraph::CGRAPH_ECHO("----> [MyTimerAspect] [%s] time cost is : [%0.2lf] ms",
29 this->getName().c_str(), span.count());
30 }
31
32private:
33 std::chrono::steady_clock::time_point start_ts_;
34};
35
36#endif //CGRAPH_MYTIMERASPECT_H

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected