Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions http2/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def run_benchmark(remote_host=None):
CLIENT_BINARY_PATH,
"--stderrthreshold=0",
"--benchmark_counters_tabular=true",
"--benchmark_min_time=5.0s",
f"--host={client_host}",
], capture_output=False, text=True, check=True)
except subprocess.CalledProcessError as e:
Expand Down
22 changes: 12 additions & 10 deletions http2/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct ClientSession {
int total_requests_submitted;
std::map<int32_t, std::chrono::steady_clock::time_point> request_start_times;
std::map<int32_t, size_t> response_sizes;
std::vector<double> latencies;
std::vector<double> latencies_us;
};

static void submit_request(struct ClientSession* client);
Expand Down Expand Up @@ -75,8 +75,8 @@ static void complete_request(struct ClientSession* client, int32_t stream_id) {
auto it = client->request_start_times.find(stream_id);
if (it != client->request_start_times.end()) {
auto end_time = std::chrono::steady_clock::now();
double duration = std::chrono::duration<double, std::milli>(end_time - it->second).count();
client->latencies.push_back(duration);
double duration = std::chrono::duration<double, std::micro>(end_time - it->second).count();
client->latencies_us.push_back(duration);
client->request_start_times.erase(it);
}

Expand Down Expand Up @@ -291,16 +291,16 @@ static void BM_HTTP2Client(benchmark::State& state) {
event_base_dispatch(base);
}

if (!client.latencies.empty()) {
std::sort(client.latencies.begin(), client.latencies.end());
if (!client.latencies_us.empty()) {
std::sort(client.latencies_us.begin(), client.latencies_us.end());

state.counters["p10_latency_ms"] = client.latencies[client.latencies.size() * 0.10];
state.counters["p50_latency_ms"] = client.latencies[client.latencies.size() * 0.50];
state.counters["p90_latency_ms"] = client.latencies[client.latencies.size() * 0.90];
state.counters["p99_latency_ms"] = client.latencies[client.latencies.size() * 0.99];
state.counters["p10_latency_us"] = client.latencies_us[client.latencies_us.size() * 0.10];
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to print latencies in microsecond

state.counters["p50_latency_us"] = client.latencies_us[client.latencies_us.size() * 0.50];
state.counters["p90_latency_us"] = client.latencies_us[client.latencies_us.size() * 0.90];
state.counters["p99_latency_us"] = client.latencies_us[client.latencies_us.size() * 0.99];

// Calculates QPS.
state.SetItemsProcessed(client.latencies.size());
state.SetItemsProcessed(client.latencies_us.size());
}

if (client.session) nghttp2_session_del(client.session);
Expand All @@ -310,6 +310,8 @@ static void BM_HTTP2Client(benchmark::State& state) {
}

BENCHMARK(BM_HTTP2Client)
->UseRealTime()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing to report real-time as the benchmark involves network communications

->Unit(benchmark::kMicrosecond)
->Args({0})
->Args({1 << 10})
->Args({2 << 10})
Expand Down