Skip to content

Commit

Permalink
update the usage about GET_CURRENT_MS
Browse files Browse the repository at this point in the history
  • Loading branch information
holmes1412 committed Nov 19, 2021
1 parent c9194e8 commit f3034ec
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions benchmark/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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")
{
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions benchmark/client_cdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using namespace srpc;

#define TEST_SECOND 20
#define GET_CURRENT_MS std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count()
#define GET_CURRENT_NS std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now().time_since_epoch()).count()

std::atomic<int> query_count(0);
Expand Down Expand Up @@ -160,7 +159,7 @@ int main(int argc, char* argv[])

latency_lists.resize(PARALLEL_NUMBER);
std::vector<std::thread *> th;
int64_t start = GET_CURRENT_MS;
int64_t start = GET_CURRENT_MS();

if (server_type == "srpc")
{
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion benchmark/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/module/rpc_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/module/rpc_module_span.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ bool RPCSpanModule<RPCTYPE>::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
}
Expand All @@ -203,7 +203,7 @@ bool RPCSpanModule<RPCTYPE>::client_end(SubTask *task,
auto *client_task = static_cast<CLIENT_TASK *>(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];
Expand Down Expand Up @@ -253,7 +253,7 @@ bool RPCSpanModule<RPCTYPE>::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;
Expand All @@ -278,7 +278,7 @@ bool RPCSpanModule<RPCTYPE>::server_end(SubTask *task,
auto *server_task = static_cast<SERVER_TASK *>(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 -
Expand Down
2 changes: 1 addition & 1 deletion src/module/rpc_span_policies.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion src/rpc_task.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "{\"";

Expand Down

0 comments on commit f3034ec

Please sign in to comment.