diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-06-21 09:21:32 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-06-21 09:21:32 +0000 |
commit | 31dcb4cf3448b7384f70b6ddaa82c42842fa35bd (patch) | |
tree | 62706692af7fb46827e83d737d19552408cbf9a0 /fbench/src/fbench/fbench.cpp | |
parent | 1fd7aa975463ffc97e13dbfc7a862703b623c356 (diff) |
Compute percentage of zero hit queries.
Diffstat (limited to 'fbench/src/fbench/fbench.cpp')
-rw-r--r-- | fbench/src/fbench/fbench.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/fbench/src/fbench/fbench.cpp b/fbench/src/fbench/fbench.cpp index 57efb8a47e0..1ba49e9897a 100644 --- a/fbench/src/fbench/fbench.cpp +++ b/fbench/src/fbench/fbench.cpp @@ -1,4 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "fbench.h" +#include "client.h" + #include <util/timer.h> #include <httpclient/httpclient.h> #include <util/filereader.h> @@ -9,8 +13,6 @@ #include <vespa/vespalib/net/tls/tls_crypto_engine.h> #include <vespa/vespalib/io/mapped_file_input.h> #include <vespa/vespalib/util/size_literals.h> -#include "client.h" -#include "fbench.h" #include <cstring> #include <cmath> #include <csignal> @@ -19,7 +21,8 @@ namespace { -std::string maybe_load(const std::string &file_name, bool &failed) { +std::string +maybe_load(const std::string &file_name, bool &failed) { std::string content; if (!file_name.empty()) { vespalib::MappedFileInput file(file_name); @@ -42,8 +45,8 @@ FBench::FBench() _clients(), _ignoreCount(0), _cycle(0), - _filenamePattern(NULL), - _outputPattern(NULL), + _filenamePattern(), + _outputPattern(), _byteLimit(0), _restartLimit(0), _maxLineSize(0), @@ -58,8 +61,6 @@ FBench::FBench() FBench::~FBench() { _clients.clear(); - free(_filenamePattern); - free(_outputPattern); } bool @@ -121,11 +122,13 @@ FBench::InitBenchmark(int numClients, int ignoreCount, int cycle, _ignoreCount = ignoreCount; _cycle = cycle; - free(_filenamePattern); - _filenamePattern = strdup(filenamePattern); - free(_outputPattern); - _outputPattern = (outputPattern == NULL) ? - NULL : strdup(outputPattern); + _filenamePattern = filenamePattern; + if (outputPattern != nullptr) { + _outputPattern = outputPattern; + } else { + _outputPattern.clear(); + } + _queryStringToAppend = queryStringToAppend; _extraHeaders = extraHeaders; _authority = authority; @@ -154,15 +157,12 @@ FBench::CreateClients() off_end = _queryfileOffset[i+1]; } client = std::make_unique<Client>(_crypto_engine, - new ClientArguments(i, _clients.size(), _filenamePattern, - _outputPattern, _hostnames[i % _hostnames.size()].c_str(), - _ports[i % _ports.size()], _cycle, - random() % spread, _ignoreCount, - _byteLimit, _restartLimit, _maxLineSize, - _keepAlive, _base64Decode, - _headerBenchmarkdataCoverage, - off_beg, off_end, - _singleQueryFile, _queryStringToAppend, _extraHeaders, _authority, _usePostMode)); + std::make_unique<ClientArguments>(i, _filenamePattern, _outputPattern, + _hostnames[i % _hostnames.size()].c_str(), + _ports[i % _ports.size()], _cycle,random() % spread, + _ignoreCount, _byteLimit, _restartLimit, _maxLineSize, _keepAlive, + _base64Decode, _headerBenchmarkdataCoverage, off_beg, off_end, + _singleQueryFile, _queryStringToAppend, _extraHeaders, _authority, _usePostMode)); ++i; } } @@ -278,6 +278,8 @@ FBench::PrintSummary() printf("utilization: %8.2f %%\n", (maxRate > 0) ? 100 * (actualRate / maxRate) : 0); printf("zero hit queries: %8ld\n", status._zeroHitQueries); + printf("zero hit percentage: %8.2f %%\n", + (status._requestCnt > 0) ? 100.0*(double(status._zeroHitQueries)/status._requestCnt) : 0.0); printf("http request status breakdown:\n"); for (const auto& entry : status._requestStatusDistribution) printf(" %8u : %8u \n", entry.first, entry.second); @@ -345,7 +347,7 @@ FBench::Main(int argc, char *argv[]) const int minLineSize = 1024; const char *queryFilePattern = "query%03d.txt"; - const char *outputFilePattern = NULL; + const char *outputFilePattern = nullptr; std::string queryStringToAppend; std::string extraHeaders; std::string ca_certs_file_name; // -T @@ -599,8 +601,8 @@ main(int argc, char** argv) sigemptyset(&act.sa_mask); act.sa_flags = 0; - sigaction(SIGINT, &act, NULL); - sigaction(SIGPIPE, &act, NULL); + sigaction(SIGINT, &act, nullptr); + sigaction(SIGPIPE, &act, nullptr); FBench myApp; return myApp.Main(argc, argv); |