Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit 2fd0e55

Browse filesBrowse files
committed
throughput benchmark memory leak fix
1 parent 9366904 commit 2fd0e55
Copy full SHA for 2fd0e55

File tree

1 file changed

+10
-4
lines changed
Filter options

1 file changed

+10
-4
lines changed

‎benchmark/throughput.cc

Copy file name to clipboardExpand all lines: benchmark/throughput.cc
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "core/client.h"
1010
#include "network/tcp/tcp_server.h"
11+
#include "module/logger.h"
1112

1213
#include <chrono>
1314
#include <ctime>
@@ -62,6 +63,8 @@ int main(int argc, const char *argv[]) {
6263
bool decode_value = variables["decode-value"].as<bool>();
6364
int min_send_num = variables["num-message"].as<int>();
6465

66+
Logger::_().level = Logger::INFO__;
67+
6568
std::cout << std::endl << "benchmark with " << client_count << " clients";
6669

6770
auto app = std::make_shared<App>();
@@ -128,6 +131,8 @@ int main(int argc, const char *argv[]) {
128131
tick = [&](const boost::system::error_code &error) {
129132

130133
if (!error) {
134+
135+
if (server_strand.strand == nullptr) return;
131136
server_strand.strand->dispatch([&]() {
132137
auto ts2 = high_resolution_clock::now();
133138

@@ -195,6 +200,11 @@ int main(int argc, const char *argv[]) {
195200
destroy_client_in_strand(clients[i]);
196201
}
197202

203+
server_strand.destroy();
204+
for (int i = 0; i < client_count; ++i) {
205+
client_strands[i].destroy();
206+
}
207+
198208
app->close();
199209

200210
wait_for_bool(500, [&]() -> bool { return app->is_stopped(); });
@@ -203,10 +213,6 @@ int main(int argc, const char *argv[]) {
203213
app->force_stop();
204214
}
205215

206-
server_strand.destroy();
207-
for (int i = 0; i < client_count; ++i) {
208-
client_strands[i].destroy();
209-
}
210216
app->wait();
211217
return 0;
212218
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.