Skip to content

Commit 8ebd746

Browse files
committed
fix msvc warning 4244
1 parent 87c3814 commit 8ebd746

6 files changed

+14
-9
lines changed

myframe/worker_timer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace myframe {
1919

2020
uint64_t TimerManager::GetMonoTimeMs() {
2121
auto now = std::chrono::steady_clock::now();
22-
return now.time_since_epoch().count() / 1e6;
22+
return static_cast<uint64_t>(now.time_since_epoch().count() / 1e6);
2323
}
2424

2525
TimerManager::TimerManager() {

test/performance_trans100_fullspeed_test.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class FullSpeed100ActorTransTest : public myframe::Actor {
6767
LOG(INFO) << "100 actor fullspeed trans msg avg(cnt/sec): " << avg;
6868
std::sort(msg_cnt_per_sec_list_.begin(), msg_cnt_per_sec_list_.end());
6969
LOG(INFO) << "100 actor fullspeed trans msg 99(cnt/sec): "
70-
<< msg_cnt_per_sec_list_[msg_cnt_per_sec_list_.size() * 0.99];
70+
<< msg_cnt_per_sec_list_[
71+
static_cast<size_t>(msg_cnt_per_sec_list_.size() * 0.99)];
7172
GetApp()->Quit();
7273
}
7374
}

test/performance_trans10_cost_test.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class Trans10ActorCostTest : public myframe::Actor {
7575
LOG(INFO) << "trans 10 actor avg(us): " << avg;
7676
std::sort(cost_us_list_.begin(), cost_us_list_.end());
7777
LOG(INFO) << "trans 10 actor 99(us): " <<
78-
cost_us_list_[cost_us_list_.size() * 0.99];
78+
cost_us_list_[
79+
static_cast<size_t>(cost_us_list_.size() * 0.99)];
7980
GetApp()->Quit();
8081
}
8182
}
@@ -84,14 +85,14 @@ class Trans10ActorCostTest : public myframe::Actor {
8485
static bool init_;
8586
static std::chrono::high_resolution_clock::time_point total_;
8687
static std::chrono::high_resolution_clock::time_point begin_;
87-
static std::vector<int> cost_us_list_;
88+
static std::vector<int64_t> cost_us_list_;
8889
int task_num_{0};
8990
std::string msg_;
9091
};
9192
bool Trans10ActorCostTest::init_{false};
9293
std::chrono::high_resolution_clock::time_point Trans10ActorCostTest::total_;
9394
std::chrono::high_resolution_clock::time_point Trans10ActorCostTest::begin_;
94-
std::vector<int> Trans10ActorCostTest::cost_us_list_;
95+
std::vector<int64_t> Trans10ActorCostTest::cost_us_list_;
9596

9697

9798
int main() {

test/performance_trans1_cost_test.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class TransMsgCostTest : public myframe::Actor {
6060
LOG(INFO) << "trans 1 actor avg(us): " << avg;
6161
std::sort(cost_us_list_.begin(), cost_us_list_.end());
6262
LOG(INFO) << "trans 1 actor 99(us): " <<
63-
cost_us_list_[cost_us_list_.size() * 0.99];
63+
cost_us_list_[
64+
static_cast<size_t>(cost_us_list_.size() * 0.99)];
6465
GetApp()->Quit();
6566
}
6667
}
@@ -69,7 +70,7 @@ class TransMsgCostTest : public myframe::Actor {
6970
std::chrono::high_resolution_clock::time_point begin_;
7071
std::chrono::high_resolution_clock::time_point last_;
7172
std::string msg_;
72-
std::vector<int> cost_us_list_;
73+
std::vector<int64_t> cost_us_list_;
7374
};
7475

7576
int main() {

test/performance_trans1_fullspeed_test.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class FullSpeedTransTest : public myframe::Actor {
6464
LOG(INFO) << "1 actor fullspeed trans msg avg(cnt/sec): " << avg;
6565
std::sort(msg_cnt_per_sec_list_.begin(), msg_cnt_per_sec_list_.end());
6666
LOG(INFO) << "1 actor fullspeed trans msg 99(cnt/sec): "
67-
<< msg_cnt_per_sec_list_[msg_cnt_per_sec_list_.size() * 0.99];
67+
<< msg_cnt_per_sec_list_[
68+
static_cast<size_t>(msg_cnt_per_sec_list_.size() * 0.99)];
6869
GetApp()->Quit();
6970
}
7071
}

test/performance_trans20_fullspeed_test.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class FullSpeed20ActorTransTest : public myframe::Actor {
6666
LOG(INFO) << "20 actor fullspeed trans msg avg(cnt/sec): " << avg;
6767
std::sort(msg_cnt_per_sec_list_.begin(), msg_cnt_per_sec_list_.end());
6868
LOG(INFO) << "20 actor fullspeed trans msg 99(cnt/sec): "
69-
<< msg_cnt_per_sec_list_[msg_cnt_per_sec_list_.size() * 0.99];
69+
<< msg_cnt_per_sec_list_[
70+
static_cast<size_t>(msg_cnt_per_sec_list_.size() * 0.99)];
7071
GetApp()->Quit();
7172
}
7273
}

0 commit comments

Comments
 (0)