connect_benchmark.cpp revision d46aa71fdad655f9dc2e33e0fbb96a776a55d095
12cf561722c2661cc0d4db502a44a3021609f307eRobin Lee/* 22cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * Copyright (C) 2016 The Android Open Source Project 32cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * 42cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * Licensed under the Apache License, Version 2.0 (the "License"); 52cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * you may not use this file except in compliance with the License. 62cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * You may obtain a copy of the License at 72cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * 82cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * http://www.apache.org/licenses/LICENSE-2.0 92cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * 102cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * Unless required by applicable law or agreed to in writing, software 112cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * distributed under the License is distributed on an "AS IS" BASIS, 122cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * See the License for the specific language governing permissions and 142cf561722c2661cc0d4db502a44a3021609f307eRobin Lee * limitations under the License. 152cf561722c2661cc0d4db502a44a3021609f307eRobin Lee */ 162cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 172cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#define LOG_TAG "connect_benchmark" 182cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 192cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <arpa/inet.h> 202cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <cutils/sockets.h> 212cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <errno.h> 222cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <netinet/in.h> 232cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <time.h> 242cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 252cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <map> 262cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <functional> 272cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <thread> 282cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 292cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <android-base/stringprintf.h> 302cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <benchmark/benchmark.h> 312cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <log/log.h> 322cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include <utils/StrongPointer.h> 332cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 342cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include "FwmarkClient.h" 352cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include "SockDiag.h" 362cf561722c2661cc0d4db502a44a3021609f307eRobin Lee#include "Stopwatch.h" 37d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski#include "android/net/metrics/INetdEventListener.h" 382cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 392cf561722c2661cc0d4db502a44a3021609f307eRobin Leeusing android::base::StringPrintf; 40d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinskiusing android::net::metrics::INetdEventListener; 412cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 422cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic int bindAndListen(int s) { 432cf561722c2661cc0d4db502a44a3021609f307eRobin Lee sockaddr_in6 sin6 = { .sin6_family = AF_INET6 }; 442cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (bind(s, (sockaddr*) &sin6, sizeof(sin6)) == 0) { 452cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (listen(s, 1)) { 462cf561722c2661cc0d4db502a44a3021609f307eRobin Lee return -1; 472cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 482cf561722c2661cc0d4db502a44a3021609f307eRobin Lee sockaddr_in sin = {}; 492cf561722c2661cc0d4db502a44a3021609f307eRobin Lee socklen_t len = sizeof(sin); 502cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (getsockname(s, (sockaddr*) &sin, &len)) { 512cf561722c2661cc0d4db502a44a3021609f307eRobin Lee return -1; 522cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 532cf561722c2661cc0d4db502a44a3021609f307eRobin Lee return ntohs(sin.sin_port); 542cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } else { 552cf561722c2661cc0d4db502a44a3021609f307eRobin Lee return -1; 562cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 572cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 582cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 592cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv4_loopback(benchmark::State& state, const bool waitBetweenRuns) { 602cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const int listensocket = socket(AF_INET6, SOCK_STREAM, 0); 612cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const int port = bindAndListen(listensocket); 622cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (port == -1) { 632cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SkipWithError("Unable to bind server socket"); 642cf561722c2661cc0d4db502a44a3021609f307eRobin Lee return; 652cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 662cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 672cf561722c2661cc0d4db502a44a3021609f307eRobin Lee // ALOGW("Listening on port = %d", port); 682cf561722c2661cc0d4db502a44a3021609f307eRobin Lee std::vector<uint64_t> latencies(state.max_iterations); 692cf561722c2661cc0d4db502a44a3021609f307eRobin Lee uint64_t iterations = 0; 702cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 712cf561722c2661cc0d4db502a44a3021609f307eRobin Lee while (state.KeepRunning()) { 722cf561722c2661cc0d4db502a44a3021609f307eRobin Lee int sock = socket(AF_INET, SOCK_STREAM, 0); 732cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (sock < 0) { 742cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SkipWithError(StringPrintf("socket() failed with errno=%d", errno).c_str()); 752cf561722c2661cc0d4db502a44a3021609f307eRobin Lee break; 762cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 772cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 782cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const Stopwatch stopwatch; 792cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 802cf561722c2661cc0d4db502a44a3021609f307eRobin Lee sockaddr_in server = { .sin_family = AF_INET, .sin_port = htons(port) }; 812cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (auto ret = connect(sock, (sockaddr*) &server, sizeof(server))) { 822cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SkipWithError(StringPrintf("connect() failed with errno=%d", errno).c_str()); 832cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(sock); 842cf561722c2661cc0d4db502a44a3021609f307eRobin Lee break; 852cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 862cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 872cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (waitBetweenRuns) { 882cf561722c2661cc0d4db502a44a3021609f307eRobin Lee latencies[iterations] = stopwatch.timeTaken() * 1e6L; 892cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SetIterationTime(latencies[iterations] / 1e9L); 902cf561722c2661cc0d4db502a44a3021609f307eRobin Lee std::this_thread::sleep_for(std::chrono::milliseconds(10)); 912cf561722c2661cc0d4db502a44a3021609f307eRobin Lee ++iterations; 922cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 932cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 942cf561722c2661cc0d4db502a44a3021609f307eRobin Lee sockaddr_in6 client; 952cf561722c2661cc0d4db502a44a3021609f307eRobin Lee socklen_t clientlen = sizeof(client); 962cf561722c2661cc0d4db502a44a3021609f307eRobin Lee int accepted = accept(listensocket, (sockaddr *) &client, &clientlen); 972cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (accepted < 0) { 982cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SkipWithError(StringPrintf("accept() failed with errno=%d", errno).c_str()); 992cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(sock); 1002cf561722c2661cc0d4db502a44a3021609f307eRobin Lee break; 1012cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1022cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1032cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(accepted); 1042cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(sock); 1052cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1062cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(listensocket); 1072cf561722c2661cc0d4db502a44a3021609f307eRobin Lee // ALOGI("Finished test on port = %d", port); 1082cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1092cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (iterations > 0) { 1102cf561722c2661cc0d4db502a44a3021609f307eRobin Lee latencies.resize(iterations); 1112cf561722c2661cc0d4db502a44a3021609f307eRobin Lee sort(latencies.begin(), latencies.end()); 1122cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SetLabel(StringPrintf("%lld", (long long) latencies[iterations * 9 / 10])); 1132cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1142cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 1152cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1162cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv6_loopback(benchmark::State& state, const bool waitBetweenRuns) { 1172cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const int listensocket = socket(AF_INET6, SOCK_STREAM, 0); 1182cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const int port = bindAndListen(listensocket); 1192cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (port == -1) { 1202cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SkipWithError("Unable to bind server socket"); 1212cf561722c2661cc0d4db502a44a3021609f307eRobin Lee return; 1222cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1232cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1242cf561722c2661cc0d4db502a44a3021609f307eRobin Lee // ALOGW("Listening on port = %d", port); 1252cf561722c2661cc0d4db502a44a3021609f307eRobin Lee std::vector<uint64_t> latencies(state.max_iterations); 1262cf561722c2661cc0d4db502a44a3021609f307eRobin Lee uint64_t iterations = 0; 1272cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1282cf561722c2661cc0d4db502a44a3021609f307eRobin Lee while (state.KeepRunning()) { 1292cf561722c2661cc0d4db502a44a3021609f307eRobin Lee int sock = socket(AF_INET6, SOCK_STREAM, 0); 1302cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (sock < 0) { 1312cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SkipWithError(StringPrintf("socket() failed with errno=%d", errno).c_str()); 1322cf561722c2661cc0d4db502a44a3021609f307eRobin Lee break; 1332cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1342cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1352cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const Stopwatch stopwatch; 1362cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1372cf561722c2661cc0d4db502a44a3021609f307eRobin Lee sockaddr_in6 server = { .sin6_family = AF_INET6, .sin6_port = htons(port) }; 1382cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (auto ret = connect(sock, (sockaddr*) &server, sizeof(server))) { 1392cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SkipWithError(StringPrintf("connect() failed with errno=%d", errno).c_str()); 1402cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(sock); 1412cf561722c2661cc0d4db502a44a3021609f307eRobin Lee break; 1422cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1432cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1442cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (waitBetweenRuns) { 1452cf561722c2661cc0d4db502a44a3021609f307eRobin Lee latencies[iterations] = stopwatch.timeTaken() * 1e6L; 1462cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SetIterationTime(latencies[iterations] / 1e9L); 1472cf561722c2661cc0d4db502a44a3021609f307eRobin Lee std::this_thread::sleep_for(std::chrono::milliseconds(10)); 1482cf561722c2661cc0d4db502a44a3021609f307eRobin Lee ++iterations; 1492cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1502cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1512cf561722c2661cc0d4db502a44a3021609f307eRobin Lee sockaddr_in6 client; 1522cf561722c2661cc0d4db502a44a3021609f307eRobin Lee socklen_t clientlen = sizeof(client); 1532cf561722c2661cc0d4db502a44a3021609f307eRobin Lee int accepted = accept(listensocket, (sockaddr *) &client, &clientlen); 1542cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (accepted < 0) { 1552cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SkipWithError(StringPrintf("accept() failed with errno=%d", errno).c_str()); 1562cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(sock); 1572cf561722c2661cc0d4db502a44a3021609f307eRobin Lee break; 1582cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1592cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1602cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(accepted); 1612cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(sock); 1622cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1632cf561722c2661cc0d4db502a44a3021609f307eRobin Lee close(listensocket); 1642cf561722c2661cc0d4db502a44a3021609f307eRobin Lee // ALOGI("Finished test on port = %d", port); 1652cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1662cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (iterations > 0) { 1672cf561722c2661cc0d4db502a44a3021609f307eRobin Lee latencies.resize(iterations); 1682cf561722c2661cc0d4db502a44a3021609f307eRobin Lee sort(latencies.begin(), latencies.end()); 1692cf561722c2661cc0d4db502a44a3021609f307eRobin Lee state.SetLabel(StringPrintf("%lld", (long long) latencies[iterations * 9 / 10])); 1702cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1712cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 1722cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1732cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void run_at_reporting_level(decltype(ipv4_loopback) benchmarkFunction, 174d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski ::benchmark::State& state, const int reportingLevel, 1752cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const bool waitBetweenRuns) { 1762cf561722c2661cc0d4db502a44a3021609f307eRobin Lee // Our master thread (thread_index == 0) will control setup and teardown for other threads. 1772cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const bool isMaster = (state.thread_index == 0); 1782cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1792cf561722c2661cc0d4db502a44a3021609f307eRobin Lee // Previous values of env variables used by fwmarkclient (only read/written by master thread) 1802cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const std::string savedSettings[] = { 1812cf561722c2661cc0d4db502a44a3021609f307eRobin Lee FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT, 1822cf561722c2661cc0d4db502a44a3021609f307eRobin Lee FwmarkClient::ANDROID_FWMARK_METRICS_ONLY 1832cf561722c2661cc0d4db502a44a3021609f307eRobin Lee }; 1842cf561722c2661cc0d4db502a44a3021609f307eRobin Lee std::map<std::string, std::string> prevSettings; 1852cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 1862cf561722c2661cc0d4db502a44a3021609f307eRobin Lee // SETUP 1872cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (isMaster) { 1882cf561722c2661cc0d4db502a44a3021609f307eRobin Lee for (const auto setting : savedSettings) { 1892cf561722c2661cc0d4db502a44a3021609f307eRobin Lee const char* prevEnvStr = getenv(setting.c_str()); 1902cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (prevEnvStr != nullptr) { 1912cf561722c2661cc0d4db502a44a3021609f307eRobin Lee prevSettings[setting.c_str()] = prevEnvStr; 1922cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1932cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 1942cf561722c2661cc0d4db502a44a3021609f307eRobin Lee switch (reportingLevel) { 195d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski case INetdEventListener::REPORTING_LEVEL_NONE: 1962cf561722c2661cc0d4db502a44a3021609f307eRobin Lee setenv(FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT, "", 1); 1972cf561722c2661cc0d4db502a44a3021609f307eRobin Lee break; 198d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski case INetdEventListener::REPORTING_LEVEL_METRICS: 1992cf561722c2661cc0d4db502a44a3021609f307eRobin Lee unsetenv(FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT); 2002cf561722c2661cc0d4db502a44a3021609f307eRobin Lee setenv(FwmarkClient::ANDROID_FWMARK_METRICS_ONLY, "", 1); 2012cf561722c2661cc0d4db502a44a3021609f307eRobin Lee break; 202d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski case INetdEventListener::REPORTING_LEVEL_FULL: 2032cf561722c2661cc0d4db502a44a3021609f307eRobin Lee unsetenv(FwmarkClient::ANDROID_NO_USE_FWMARK_CLIENT); 2042cf561722c2661cc0d4db502a44a3021609f307eRobin Lee unsetenv(FwmarkClient::ANDROID_FWMARK_METRICS_ONLY); 2052cf561722c2661cc0d4db502a44a3021609f307eRobin Lee break; 2062cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 2072cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 2082cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2092cf561722c2661cc0d4db502a44a3021609f307eRobin Lee // TEST 2102cf561722c2661cc0d4db502a44a3021609f307eRobin Lee benchmarkFunction(state, waitBetweenRuns); 2112cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2122cf561722c2661cc0d4db502a44a3021609f307eRobin Lee // TEARDOWN 2132cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (isMaster) { 2142cf561722c2661cc0d4db502a44a3021609f307eRobin Lee for (const auto setting : savedSettings) { 2152cf561722c2661cc0d4db502a44a3021609f307eRobin Lee if (prevSettings.count(setting)) { 2162cf561722c2661cc0d4db502a44a3021609f307eRobin Lee setenv(setting.c_str(), prevSettings[setting].c_str(), 1); 2172cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } else { 2182cf561722c2661cc0d4db502a44a3021609f307eRobin Lee unsetenv(setting.c_str()); 2192cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 2202cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 2212cf561722c2661cc0d4db502a44a3021609f307eRobin Lee } 2222cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2232cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2242cf561722c2661cc0d4db502a44a3021609f307eRobin Leeconstexpr int MIN_THREADS = 1; 2252cf561722c2661cc0d4db502a44a3021609f307eRobin Leeconstexpr int MAX_THREADS = 1; 2262cf561722c2661cc0d4db502a44a3021609f307eRobin Leeconstexpr double MIN_TIME = 0.5 /* seconds */; 2272cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2282cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv4_metrics_reporting_no_fwmark(::benchmark::State& state) { 229d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_NONE, true); 2302cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2312cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv4_metrics_reporting_no_fwmark)->MinTime(MIN_TIME)->UseManualTime(); 2322cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2332cf561722c2661cc0d4db502a44a3021609f307eRobin Lee// IPv4 metrics under low load 2342cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv4_metrics_reporting_no_load(::benchmark::State& state) { 235d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, true); 2362cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2372cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv4_metrics_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime(); 2382cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2392cf561722c2661cc0d4db502a44a3021609f307eRobin Lee/* 2402cf561722c2661cc0d4db502a44a3021609f307eRobin Lee// TODO: uncomment once full reporting is available. 2412cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv4_full_reporting_no_load(::benchmark::State& state) { 242d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, true); 2432cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2442cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv4_full_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime(); 2452cf561722c2661cc0d4db502a44a3021609f307eRobin Lee*/ 2462cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2472cf561722c2661cc0d4db502a44a3021609f307eRobin Lee// IPv4 benchmarks under high load 2482cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv4_metrics_reporting_high_load(::benchmark::State& state) { 249d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, 250d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski false); 2512cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2522cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv4_metrics_reporting_high_load) 2532cf561722c2661cc0d4db502a44a3021609f307eRobin Lee ->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime(); 2542cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2552cf561722c2661cc0d4db502a44a3021609f307eRobin Lee/* 2562cf561722c2661cc0d4db502a44a3021609f307eRobin Lee// TODO: uncomment once full reporting is available. 2572cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv4_full_reporting_high_load(::benchmark::State& state) { 258d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv4_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, false); 2592cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2602cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv4_full_reporting_high_load) 2612cf561722c2661cc0d4db502a44a3021609f307eRobin Lee ->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime(); 2622cf561722c2661cc0d4db502a44a3021609f307eRobin Lee*/ 2632cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2642cf561722c2661cc0d4db502a44a3021609f307eRobin Lee// IPv6 raw connect() without using fwmark 2652cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv6_metrics_reporting_no_fwmark(::benchmark::State& state) { 266d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_NONE, true); 2672cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2682cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv6_metrics_reporting_no_fwmark)->MinTime(MIN_TIME)->UseManualTime(); 2692cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2702cf561722c2661cc0d4db502a44a3021609f307eRobin Lee// IPv6 metrics under low load 2712cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv6_metrics_reporting_no_load(::benchmark::State& state) { 272d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, true); 2732cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2742cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv6_metrics_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime(); 2752cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2762cf561722c2661cc0d4db502a44a3021609f307eRobin Lee/* 2772cf561722c2661cc0d4db502a44a3021609f307eRobin Lee// TODO: uncomment once full reporting is available. 2782cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv6_full_reporting_no_load(::benchmark::State& state) { 279d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, true); 2802cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2812cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv6_full_reporting_no_load)->MinTime(MIN_TIME)->UseManualTime(); 2822cf561722c2661cc0d4db502a44a3021609f307eRobin Lee*/ 2832cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2842cf561722c2661cc0d4db502a44a3021609f307eRobin Lee// IPv6 benchmarks under high load 2852cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv6_metrics_reporting_high_load(::benchmark::State& state) { 286d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_METRICS, 287d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski false); 2882cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2892cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv6_metrics_reporting_high_load) 2902cf561722c2661cc0d4db502a44a3021609f307eRobin Lee ->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime(); 2912cf561722c2661cc0d4db502a44a3021609f307eRobin Lee 2922cf561722c2661cc0d4db502a44a3021609f307eRobin Lee/* 2932cf561722c2661cc0d4db502a44a3021609f307eRobin Lee// TODO: uncomment once full reporting is available. 2942cf561722c2661cc0d4db502a44a3021609f307eRobin Leestatic void ipv6_full_reporting_high_load(::benchmark::State& state) { 295d46aa71fdad655f9dc2e33e0fbb96a776a55d095Michal Karpinski run_at_reporting_level(ipv6_loopback, state, INetdEventListener::REPORTING_LEVEL_FULL, false); 2962cf561722c2661cc0d4db502a44a3021609f307eRobin Lee} 2972cf561722c2661cc0d4db502a44a3021609f307eRobin LeeBENCHMARK(ipv6_full_reporting_high_load) 2982cf561722c2661cc0d4db502a44a3021609f307eRobin Lee ->ThreadRange(MIN_THREADS, MAX_THREADS)->MinTime(MIN_TIME)->UseRealTime(); 2992cf561722c2661cc0d4db502a44a3021609f307eRobin Lee*/ 300