aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@vespa.ai>2024-06-04 17:22:50 +0200
committerGitHub <noreply@github.com>2024-06-04 17:22:50 +0200
commit1165e5c5515fbb04489daa2e6f37b71a39c22255 (patch)
tree56a8c214e485935f2af8c7546cae7b0128d54240 /searchlib
parent47e5501650ac742242be305f06a93c1a41698809 (diff)
parent48a1edcb38d01a388c9e5d943440300c324ea5ea (diff)
Merge pull request #31430 from vespa-engine/toregge/stop-using-vespalib-test-app-for-phase-splitter-benchmark
Stop using vespalib::TestApp for phrase splitter benchmark.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/fef/phrasesplitter/benchmark.cpp46
1 files changed, 22 insertions, 24 deletions
diff --git a/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp b/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp
index 93a5a01262d..6be252380da 100644
--- a/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp
+++ b/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp
@@ -1,18 +1,16 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/testkit/testapp.h>
+
#include <vespa/searchlib/fef/matchdatalayout.h>
#include <vespa/searchlib/fef/phrasesplitter.h>
#include <vespa/searchlib/fef/phrase_splitter_query_env.h>
#include <vespa/searchlib/fef/test/queryenvironment.h>
+#include <vespa/vespalib/util/time.h>
#include <iomanip>
#include <iostream>
-#include <vespa/log/log.h>
-LOG_SETUP("phrasesplitter_test");
-
namespace search::fef {
-class Benchmark : public vespalib::TestApp
+class Benchmark
{
private:
vespalib::Timer _timer;
@@ -20,12 +18,16 @@ private:
void start() { _timer = vespalib::Timer(); }
void sample() { _sample = _timer.elapsed(); }
- void run(size_t numRuns, size_t numPositions);
public:
- Benchmark() : _timer(), _sample(0) {}
- ~Benchmark() override;
- int Main() override;
+ Benchmark()
+ : _timer(),
+ _sample(0)
+ {
+ }
+ ~Benchmark();
+ void run(size_t numRuns, size_t numPositions);
+ vespalib::duration get_sample() const noexcept { return _sample; }
};
Benchmark::~Benchmark() = default;
@@ -61,28 +63,24 @@ Benchmark::run(size_t numRuns, size_t numPositions)
sample();
}
+}
+
int
-Benchmark::Main()
+main(int argc, char* argv[])
{
-
- TEST_INIT("benchmark");
-
- if (_argc != 3) {
+ if (argc != 3) {
std::cout << "Must specify <numRuns> and <numPositions>" << std::endl;
return 0;
}
- size_t numRuns = strtoull(_argv[1], nullptr, 10);
- size_t numPositions = strtoull(_argv[2], nullptr, 10);
+ size_t numRuns = strtoull(argv[1], nullptr, 10);
+ size_t numPositions = strtoull(argv[2], nullptr, 10);
- run(numRuns, numPositions);
+ auto app = std::make_unique<search::fef::Benchmark>();
+ app->run(numRuns, numPositions);
+ auto sample = app->get_sample();
- std::cout << "TET: " << vespalib::count_ms(_sample) << " (ms)" << std::endl;
- std::cout << "ETPD: " << std::fixed << std::setprecision(10) << (vespalib::count_ns(_sample) / (numRuns * 1000000.0)) << " (ms)" << std::endl;
+ std::cout << "TET: " << vespalib::count_ms(sample) << " (ms)" << std::endl;
+ std::cout << "ETPD: " << std::fixed << std::setprecision(10) << (vespalib::count_ns(sample) / (numRuns * 1000000.0)) << " (ms)" << std::endl;
- TEST_DONE();
}
-
-}
-
-TEST_APPHOOK(search::fef::Benchmark);