8
8
9
9
#include " core/client.h"
10
10
#include " network/tcp/tcp_server.h"
11
+ #include " module/logger.h"
11
12
12
13
#include < chrono>
13
14
#include < ctime>
@@ -62,6 +63,8 @@ int main(int argc, const char *argv[]) {
62
63
bool decode_value = variables[" decode-value" ].as <bool >();
63
64
int min_send_num = variables[" num-message" ].as <int >();
64
65
66
+ Logger::_ ().level = Logger::INFO__;
67
+
65
68
std::cout << std::endl << " benchmark with " << client_count << " clients" ;
66
69
67
70
auto app = std::make_shared<App>();
@@ -128,6 +131,8 @@ int main(int argc, const char *argv[]) {
128
131
tick = [&](const boost::system ::error_code &error) {
129
132
130
133
if (!error) {
134
+
135
+ if (server_strand.strand == nullptr ) return ;
131
136
server_strand.strand ->dispatch ([&]() {
132
137
auto ts2 = high_resolution_clock::now ();
133
138
@@ -195,6 +200,11 @@ int main(int argc, const char *argv[]) {
195
200
destroy_client_in_strand (clients[i]);
196
201
}
197
202
203
+ server_strand.destroy ();
204
+ for (int i = 0 ; i < client_count; ++i) {
205
+ client_strands[i].destroy ();
206
+ }
207
+
198
208
app->close ();
199
209
200
210
wait_for_bool (500 , [&]() -> bool { return app->is_stopped (); });
@@ -203,10 +213,6 @@ int main(int argc, const char *argv[]) {
203
213
app->force_stop ();
204
214
}
205
215
206
- server_strand.destroy ();
207
- for (int i = 0 ; i < client_count; ++i) {
208
- client_strands[i].destroy ();
209
- }
210
216
app->wait ();
211
217
return 0 ;
212
218
}
0 commit comments