| 38 | ~PerfTestServiceImpl() {} |
| 39 | |
| 40 | void Test(google::protobuf::RpcController* cntl_base, |
| 41 | const PerfTestRequest* request, |
| 42 | PerfTestResponse* response, |
| 43 | google::protobuf::Closure* done) { |
| 44 | brpc::ClosureGuard done_guard(done); |
| 45 | uint64_t last = g_last_time.load(butil::memory_order_relaxed); |
| 46 | uint64_t now = butil::monotonic_time_us(); |
| 47 | if (now > last && now - last > 100000) { |
| 48 | if (g_last_time.exchange(now, butil::memory_order_relaxed) == last) { |
| 49 | response->set_cpu_usage(bvar::Variable::describe_exposed("process_cpu_usage")); |
| 50 | } else { |
| 51 | response->set_cpu_usage(""); |
| 52 | } |
| 53 | } else { |
| 54 | response->set_cpu_usage(""); |
| 55 | } |
| 56 | if (request->echo_attachment()) { |
| 57 | brpc::Controller* cntl = |
| 58 | static_cast<brpc::Controller*>(cntl_base); |
| 59 | cntl->response_attachment().append(cntl->request_attachment()); |
| 60 | } |
| 61 | } |
| 62 | }; |
| 63 | } |
| 64 |
no test coverage detected