12 constexpr
size_t len = 100 * 1024 * 1024;
20 for (
auto it = segments.
rbegin(); it != segments.
rend(); ++it) {
24 for (
auto it = segments.
begin(); it != segments.
end(); ++it) {
35 string string_to_send(
len,
'x');
36 for (
auto &ch : string_to_send) {
44 bool x_closed =
false;
46 string string_received;
53 while (bytes_to_send.size() and x.remaining_outbound_capacity()) {
54 const auto want =
min(x.remaining_outbound_capacity(), bytes_to_send.size());
55 const auto written = x.write(
string(bytes_to_send.str().substr(0, want)));
56 if (want != written) {
59 bytes_to_send.remove_prefix(written);
62 if (bytes_to_send.size() == 0 and not x_closed) {
73 const auto available_output = y.inbound_stream().buffer_size();
74 if (available_output > 0) {
75 string_received.
append(y.inbound_stream().read(available_output));
83 while (not y.inbound_stream().eof()) {
87 if (string_received != string_to_send) {
93 const auto duration = duration_cast<nanoseconds>(final_time - first_time).
count();
95 const auto gigabits_per_second =
len * 8.0 / double(
duration);
98 cout <<
"CPU-limited throughput" << (reorder ?
" with reordering: " :
" : ") << gigabits_per_second
101 while (x.active() or y.active()) {