From f3034ec558f14f94b0d3d350cb8e92d8a683465f Mon Sep 17 00:00:00 2001 From: liyingxin Date: Fri, 19 Nov 2021 16:46:45 +0800 Subject: [PATCH] update the usage about GET_CURRENT_MS --- benchmark/client.cc | 4 ++-- benchmark/client_cdf.cc | 5 ++--- benchmark/proxy.cc | 2 +- benchmark/server.cc | 2 +- src/module/rpc_module.cc | 2 +- src/module/rpc_module_span.h | 8 ++++---- src/module/rpc_span_policies.cc | 2 +- src/rpc_task.inl | 2 +- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/benchmark/client.cc b/benchmark/client.cc index d0c56917..96bec1de 100644 --- a/benchmark/client.cc +++ b/benchmark/client.cc @@ -113,7 +113,7 @@ int main(int argc, char* argv[]) //for (int i = 0; i < REQUEST_BYTES; i++) // request_msg[i] = (unsigned char)(rand() % 256); - int64_t start = GET_CURRENT_MS; + int64_t start = GET_CURRENT_MS(); if (server_type == "srpc") { @@ -201,7 +201,7 @@ int main(int argc, char* argv[]) std::this_thread::sleep_for(std::chrono::seconds(TEST_SECOND)); stop_flag = true; - int64_t end = GET_CURRENT_MS; + int64_t end = GET_CURRENT_MS(); int tot = query_count; int s = success_count; int e = error_count; diff --git a/benchmark/client_cdf.cc b/benchmark/client_cdf.cc index df54c23f..e8036e4a 100644 --- a/benchmark/client_cdf.cc +++ b/benchmark/client_cdf.cc @@ -14,7 +14,6 @@ using namespace srpc; #define TEST_SECOND 20 -#define GET_CURRENT_MS std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count() #define GET_CURRENT_NS std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count() std::atomic query_count(0); @@ -160,7 +159,7 @@ int main(int argc, char* argv[]) latency_lists.resize(PARALLEL_NUMBER); std::vector th; - int64_t start = GET_CURRENT_MS; + int64_t start = GET_CURRENT_MS(); if (server_type == "srpc") { @@ -253,7 +252,7 @@ int main(int argc, char* argv[]) delete t; } - int64_t end = GET_CURRENT_MS; + int64_t end = GET_CURRENT_MS(); int tot = query_count - slow_count; int s = success_count; int e = error_count; diff --git a/benchmark/proxy.cc b/benchmark/proxy.cc index 4bf523e0..5181b62b 100644 --- a/benchmark/proxy.cc +++ b/benchmark/proxy.cc @@ -17,7 +17,7 @@ WFFacilities::WaitGroup wait_group(1); inline void collect_qps() { - int64_t ms_timestamp = GET_CURRENT_MS; + int64_t ms_timestamp = GET_CURRENT_MS(); ++query_count; if (ms_timestamp / 1000 > last_timestamp) { diff --git a/benchmark/server.cc b/benchmark/server.cc index 59172f1e..97cd69ce 100644 --- a/benchmark/server.cc +++ b/benchmark/server.cc @@ -15,7 +15,7 @@ WFFacilities::WaitGroup wait_group(1); inline void collect_qps() { - int64_t ms_timestamp = GET_CURRENT_MS; + int64_t ms_timestamp = GET_CURRENT_MS(); ++query_count; if (ms_timestamp / 1000 > last_timestamp) { diff --git a/src/module/rpc_module.cc b/src/module/rpc_module.cc index 5e82ec99..70525798 100644 --- a/src/module/rpc_module.cc +++ b/src/module/rpc_module.cc @@ -97,7 +97,7 @@ bool SnowFlake::get_id(long long group_id, long long machine_id, long long *uid) if (group_id > this->group_id_max || machine_id > this->machine_id_max) return false; - long long timestamp = GET_CURRENT_MS_STEADY; + long long timestamp = GET_CURRENT_MS_STEADY(); long long seq_id; if (timestamp < this->last_timestamp) diff --git a/src/module/rpc_module_span.h b/src/module/rpc_module_span.h index 7a6a0d97..d3b678b0 100644 --- a/src/module/rpc_module_span.h +++ b/src/module/rpc_module_span.h @@ -189,7 +189,7 @@ bool RPCSpanModule::client_begin(SubTask *task, module_data[SRPC_DATA_TYPE] = std::to_string(req->get_data_type()); module_data[SRPC_COMPRESS_TYPE] = std::to_string(req->get_compress_type()); - module_data[SRPC_START_TIMESTAMP] = std::to_string(GET_CURRENT_MS); + module_data[SRPC_START_TIMESTAMP] = std::to_string(GET_CURRENT_MS()); return true; // always success } @@ -203,7 +203,7 @@ bool RPCSpanModule::client_end(SubTask *task, auto *client_task = static_cast(task); auto *resp = client_task->get_resp(); RPCModuleData& module_data = *(client_task->mutable_module_data()); - long long end_time = GET_CURRENT_MS; + long long end_time = GET_CURRENT_MS(); for (auto kv : module_data) data[kv.first] = module_data[kv.first]; @@ -253,7 +253,7 @@ bool RPCSpanModule::server_begin(SubTask *task, "%0x", SRPCGlobal::get_instance()->get_span_id()); module_data[SRPC_SPAN_ID] = std::move(span_id_buf); - module_data[SRPC_START_TIMESTAMP] = std::to_string(GET_CURRENT_MS); + module_data[SRPC_START_TIMESTAMP] = std::to_string(GET_CURRENT_MS()); module_data[SRPC_COMPONENT] = SRPC_COMPONENT_SRPC; module_data[SRPC_SPAN_KIND] = SRPC_SPAN_KIND_SERVER; @@ -278,7 +278,7 @@ bool RPCSpanModule::server_end(SubTask *task, auto *server_task = static_cast(task); auto *resp = server_task->get_resp(); RPCModuleData& module_data = *(server_task->mutable_module_data()); - long long end_time = GET_CURRENT_MS; + long long end_time = GET_CURRENT_MS(); module_data[SRPC_FINISH_TIMESTAMP] = std::to_string(end_time); module_data[SRPC_DURATION] = std::to_string(end_time - diff --git a/src/module/rpc_span_policies.cc b/src/module/rpc_span_policies.cc index 71291d17..2c9ce718 100644 --- a/src/module/rpc_span_policies.cc +++ b/src/module/rpc_span_policies.cc @@ -81,7 +81,7 @@ static size_t rpc_span_log_format(RPCModuleData& data, char *str, size_t len) bool RPCSpanFilterPolicy::filter(RPCModuleData& span) { - long long timestamp = GET_CURRENT_MS; + long long timestamp = GET_CURRENT_MS(); if (timestamp < this->last_timestamp + this->stat_interval && this->spans_interval_count < this->spans_per_interval && diff --git a/src/rpc_task.inl b/src/rpc_task.inl index 75a40168..71f06cd2 100644 --- a/src/rpc_task.inl +++ b/src/rpc_task.inl @@ -613,7 +613,7 @@ static void log_format(std::string& key, std::string& value, return; char buffer[100]; - snprintf(buffer, 100, "%s%c%ld", SRPC_SPAN_LOG, ' ', GET_CURRENT_MS); + snprintf(buffer, 100, "%s%c%lld", SRPC_SPAN_LOG, ' ', GET_CURRENT_MS()); key = std::move(buffer); value = "{\"";