#include "FwmarkClient.h"
#include "SockDiag.h"
#include "Stopwatch.h"
+#include "android/net/metrics/INetdEventListener.h"
using android::base::StringPrintf;
-
-enum ReportingLevel {
- NONE,
- METRICS,
- FULL
-};
+using android::net::metrics::INetdEventListener;
static int bindAndListen(int s) {
sockaddr_in6 sin6 = { .sin6_family = AF_INET6 };
}
static void run_at_reporting_level(decltype(ipv4_loopback) benchmarkFunction,
- ::benchmark::State& state, const ReportingLevel reportingLevel,
+ ::benchmark::State& state, const int reportingLevel,
const bool waitBetweenRuns) {
// Our master thread (thread_index == 0) will control setup and teardown for other threads.
const bool isMaster = (state.thread_index == 0);
}
}
switch (reportingLevel) {
- case NONE:
+ case INetdEventListener::REPORTING_LEVEL_NONE:
setenv(FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT, "", 1);
break;
- case METRICS:
+ case INetdEventListener::REPORTING_LEVEL_METRICS:
unsetenv(FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT);
setenv(FwmarkClient::ANDROID_FWMARK_METRICS_ONLY, "", 1);
break;
- case FULL:
+ case INetdEventListener::REPORTING_LEVEL_FULL:
unsetenv(FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT);
unsetenv(FwmarkClient::ANDROID_FWMARK_METRICS_ONLY);
break;
constexpr double MIN_TIME = 0.5 /* seconds */;
static void ipv4_metrics_reporting_no_fwmark(::benchmark::State& state) {
- run_at_reporting_level(ipv4_loopback, state, NONE, true);
+ run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_NONE, true);
}
BENCHMARK(ipv4_metrics_reporting_no_fwmark)->MinTime(MIN_TIME)->UseManualTime();
// IPv4 metrics under low load
static void ipv4_metrics_reporting_no_load(::benchmark::State& state) {
- run_at_reporting_level(ipv4_loopback, state, METRICS, true);
+ run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, true);
}
BENCHMARK(ipv4_metrics_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime();
/*
// TODO: uncomment once full reporting is available.
static void ipv4_full_reporting_no_load(::benchmark::State& state) {
- run_at_reporting_level(ipv4_loopback, state, FULL, true);
+ run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, true);
}
BENCHMARK(ipv4_full_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime();
*/
// IPv4 benchmarks under high load
static void ipv4_metrics_reporting_high_load(::benchmark::State& state) {
- run_at_reporting_level(ipv4_loopback, state, METRICS, false);
+ run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS,
+ false);
}
BENCHMARK(ipv4_metrics_reporting_high_load)
->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime();
/*
// TODO: uncomment once full reporting is available.
static void ipv4_full_reporting_high_load(::benchmark::State& state) {
- run_at_reporting_level(ipv4_loopback, state, FULL, false);
+ run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, false);
}
BENCHMARK(ipv4_full_reporting_high_load)
->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime();
// IPv6 raw connect() without using fwmark
static void ipv6_metrics_reporting_no_fwmark(::benchmark::State& state) {
- run_at_reporting_level(ipv6_loopback, state, NONE, true);
+ run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_NONE, true);
}
BENCHMARK(ipv6_metrics_reporting_no_fwmark)->MinTime(MIN_TIME)->UseManualTime();
// IPv6 metrics under low load
static void ipv6_metrics_reporting_no_load(::benchmark::State& state) {
- run_at_reporting_level(ipv6_loopback, state, METRICS, true);
+ run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, true);
}
BENCHMARK(ipv6_metrics_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime();
/*
// TODO: uncomment once full reporting is available.
static void ipv6_full_reporting_no_load(::benchmark::State& state) {
- run_at_reporting_level(ipv6_loopback, state, FULL, true);
+ run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, true);
}
BENCHMARK(ipv6_full_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime();
*/
// IPv6 benchmarks under high load
static void ipv6_metrics_reporting_high_load(::benchmark::State& state) {
- run_at_reporting_level(ipv6_loopback, state, METRICS, false);
+ run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS,
+ false);
}
BENCHMARK(ipv6_metrics_reporting_high_load)
->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime();
/*
// TODO: uncomment once full reporting is available.
static void ipv6_full_reporting_high_load(::benchmark::State& state) {
- run_at_reporting_level(ipv6_loopback, state, FULL, false);
+ run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, false);
}
BENCHMARK(ipv6_full_reporting_high_load)
->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime();
#include "dns_responder_client.h"
#include "NetdClient.h"
+#include "android/net/metrics/INetdEventListener.h"
using android::base::StringPrintf;
+using android::net::metrics::INetdEventListener;
constexpr int MIN_THREADS = 1;
constexpr int MAX_THREADS = 32;
// DNS calls without any metrics logged or sent.
BENCHMARK_DEFINE_F(DnsFixture, getaddrinfo_log_nothing)(benchmark::State& state) {
- benchmark_at_reporting_level(state, 0);
+ benchmark_at_reporting_level(state, INetdEventListener::REPORTING_LEVEL_NONE);
}
BENCHMARK_REGISTER_F(DnsFixture, getaddrinfo_log_nothing)
->ThreadRange(MIN_THREADS, MAX_THREADS)
// DNS calls with metrics only (netId, latency, return code) sent to the system server.
BENCHMARK_DEFINE_F(DnsFixture, getaddrinfo_log_metrics)(benchmark::State& state) {
- benchmark_at_reporting_level(state, 1);
+ benchmark_at_reporting_level(state, INetdEventListener::REPORTING_LEVEL_METRICS);
}
BENCHMARK_REGISTER_F(DnsFixture, getaddrinfo_log_metrics)
->ThreadRange(MIN_THREADS, MAX_THREADS)
// DNS calls with all information logged and sent to the system server.
BENCHMARK_DEFINE_F(DnsFixture, getaddrinfo_log_everything)(benchmark::State& state) {
- benchmark_at_reporting_level(state, 2);
+ benchmark_at_reporting_level(state, INetdEventListener::REPORTING_LEVEL_FULL);
}
BENCHMARK_REGISTER_F(DnsFixture, getaddrinfo_log_everything)
->ThreadRange(MIN_THREADS, MAX_THREADS)