Skip to content

Commit

Permalink
fix msvc warning 4244
Browse files Browse the repository at this point in the history
  • Loading branch information
lkpworkspace committed Oct 6, 2024
1 parent 95f7184 commit 7b453b6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion myframe/worker_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace myframe {

uint64_t TimerManager::GetMonoTimeMs() {
auto now = std::chrono::steady_clock::now();
return now.time_since_epoch().count() / 1e6;
return static_cast<uint64_t>(now.time_since_epoch().count() / 1e6);
}

TimerManager::TimerManager() {
Expand Down
3 changes: 2 additions & 1 deletion test/performance_trans100_fullspeed_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class FullSpeed100ActorTransTest : public myframe::Actor {
LOG(INFO) << "100 actor fullspeed trans msg avg(cnt/sec): " << avg;
std::sort(msg_cnt_per_sec_list_.begin(), msg_cnt_per_sec_list_.end());
LOG(INFO) << "100 actor fullspeed trans msg 99(cnt/sec): "
<< msg_cnt_per_sec_list_[msg_cnt_per_sec_list_.size() * 0.99];
<< msg_cnt_per_sec_list_[
static_cast<size_t>(msg_cnt_per_sec_list_.size() * 0.99)];
GetApp()->Quit();
}
}
Expand Down
7 changes: 4 additions & 3 deletions test/performance_trans10_cost_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class Trans10ActorCostTest : public myframe::Actor {
LOG(INFO) << "trans 10 actor avg(us): " << avg;
std::sort(cost_us_list_.begin(), cost_us_list_.end());
LOG(INFO) << "trans 10 actor 99(us): " <<
cost_us_list_[cost_us_list_.size() * 0.99];
cost_us_list_[
static_cast<size_t>(cost_us_list_.size() * 0.99)];
GetApp()->Quit();
}
}
Expand All @@ -84,14 +85,14 @@ class Trans10ActorCostTest : public myframe::Actor {
static bool init_;
static std::chrono::high_resolution_clock::time_point total_;
static std::chrono::high_resolution_clock::time_point begin_;
static std::vector<int> cost_us_list_;
static std::vector<int64_t> cost_us_list_;
int task_num_{0};
std::string msg_;
};
bool Trans10ActorCostTest::init_{false};
std::chrono::high_resolution_clock::time_point Trans10ActorCostTest::total_;
std::chrono::high_resolution_clock::time_point Trans10ActorCostTest::begin_;
std::vector<int> Trans10ActorCostTest::cost_us_list_;
std::vector<int64_t> Trans10ActorCostTest::cost_us_list_;


int main() {
Expand Down
5 changes: 3 additions & 2 deletions test/performance_trans1_cost_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class TransMsgCostTest : public myframe::Actor {
LOG(INFO) << "trans 1 actor avg(us): " << avg;
std::sort(cost_us_list_.begin(), cost_us_list_.end());
LOG(INFO) << "trans 1 actor 99(us): " <<
cost_us_list_[cost_us_list_.size() * 0.99];
cost_us_list_[
static_cast<size_t>(cost_us_list_.size() * 0.99)];
GetApp()->Quit();
}
}
Expand All @@ -69,7 +70,7 @@ class TransMsgCostTest : public myframe::Actor {
std::chrono::high_resolution_clock::time_point begin_;
std::chrono::high_resolution_clock::time_point last_;
std::string msg_;
std::vector<int> cost_us_list_;
std::vector<int64_t> cost_us_list_;
};

int main() {
Expand Down
3 changes: 2 additions & 1 deletion test/performance_trans1_fullspeed_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class FullSpeedTransTest : public myframe::Actor {
LOG(INFO) << "1 actor fullspeed trans msg avg(cnt/sec): " << avg;
std::sort(msg_cnt_per_sec_list_.begin(), msg_cnt_per_sec_list_.end());
LOG(INFO) << "1 actor fullspeed trans msg 99(cnt/sec): "
<< msg_cnt_per_sec_list_[msg_cnt_per_sec_list_.size() * 0.99];
<< msg_cnt_per_sec_list_[
static_cast<size_t>(msg_cnt_per_sec_list_.size() * 0.99)];
GetApp()->Quit();
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/performance_trans20_fullspeed_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class FullSpeed20ActorTransTest : public myframe::Actor {
LOG(INFO) << "20 actor fullspeed trans msg avg(cnt/sec): " << avg;
std::sort(msg_cnt_per_sec_list_.begin(), msg_cnt_per_sec_list_.end());
LOG(INFO) << "20 actor fullspeed trans msg 99(cnt/sec): "
<< msg_cnt_per_sec_list_[msg_cnt_per_sec_list_.size() * 0.99];
<< msg_cnt_per_sec_list_[
static_cast<size_t>(msg_cnt_per_sec_list_.size() * 0.99)];
GetApp()->Quit();
}
}
Expand Down

0 comments on commit 7b453b6

Please sign in to comment.