forked from rsocket/rsocket-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamThroughputTcp.cpp
More file actions
65 lines (50 loc) · 1.92 KB
/
StreamThroughputTcp.cpp
File metadata and controls
65 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2004-present Facebook. All Rights Reserved.
#include "benchmarks/Fixture.h"
#include "benchmarks/Throughput.h"
#include <folly/Benchmark.h>
#include <folly/portability/GFlags.h>
#include <folly/synchronization/Baton.h>
#include "rsocket/RSocket.h"
using namespace rsocket;
constexpr size_t kMessageLen = 32;
DEFINE_int32(server_threads, 8, "number of server threads to run");
DEFINE_int32(
override_client_threads,
0,
"control the number of client threads (defaults to the number of clients)");
DEFINE_int32(clients, 10, "number of clients to run");
DEFINE_int32(items, 1000000, "number of items in stream, per client");
DEFINE_int32(streams, 1, "number of streams, per client");
BENCHMARK(StreamThroughput, n) {
(void)n;
Latch latch{static_cast<size_t>(FLAGS_streams)};
std::unique_ptr<Fixture> fixture;
Fixture::Options opts;
BENCHMARK_SUSPEND {
auto responder =
std::make_shared<FixedResponder>(std::string(kMessageLen, 'a'));
opts.serverThreads = FLAGS_server_threads;
opts.clients = FLAGS_clients;
if (FLAGS_override_client_threads > 0) {
opts.clientThreads = FLAGS_override_client_threads;
}
fixture = std::make_unique<Fixture>(opts, std::move(responder));
LOG(INFO) << "Running:";
LOG(INFO) << " Server with " << opts.serverThreads << " threads.";
LOG(INFO) << " " << opts.clients << " clients across "
<< fixture->workers.size() << " threads.";
LOG(INFO) << " Running " << FLAGS_streams << " streams of " << FLAGS_items
<< " items each.";
}
for (size_t i = 0; i < FLAGS_streams; ++i) {
for (auto& client : fixture->clients) {
client->getRequester()
->requestStream(Payload("TcpStream"))
->subscribe(yarpl::make_ref<BoundedSubscriber>(latch, FLAGS_items));
}
}
constexpr std::chrono::minutes timeout{5};
if (!latch.timed_wait(timeout)) {
LOG(ERROR) << "Timed out!";
}
}