aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-11-19 23:22:55 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-11-20 21:55:01 +0000
commitcf3b20dba22718b533eac6854cde86b6538958af (patch)
tree9a0e795cd74d2721140c48012f794298dfef7420 /searchlib/src/tests
parent64b7c822099d7cda921699e380c4d95608a1ab00 (diff)
FastOS_Time -> std::chrono.
Diffstat (limited to 'searchlib/src/tests')
-rw-r--r--searchlib/src/tests/aggregator/perdocexpr.cpp10
-rw-r--r--searchlib/src/tests/attribute/benchmark/attributesearcher.h29
-rw-r--r--searchlib/src/tests/attribute/benchmark/attributeupdater.h14
-rw-r--r--searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp97
-rw-r--r--searchlib/src/tests/features/featurebenchmark.cpp12
-rw-r--r--searchlib/src/tests/fef/phrasesplitter/benchmark.cpp18
-rw-r--r--searchlib/src/tests/grouping/grouping_test.cpp7
-rw-r--r--searchlib/src/tests/groupingengine/groupingengine_test.cpp7
-rw-r--r--searchlib/src/tests/postinglistbm/stress_runner.cpp30
-rw-r--r--searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp6
-rw-r--r--searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp5
-rw-r--r--searchlib/src/tests/sortspec/multilevelsort.cpp5
-rw-r--r--searchlib/src/tests/transactionlogstress/translogstress.cpp24
13 files changed, 95 insertions, 169 deletions
diff --git a/searchlib/src/tests/aggregator/perdocexpr.cpp b/searchlib/src/tests/aggregator/perdocexpr.cpp
index b8584980cf9..c078282c442 100644
--- a/searchlib/src/tests/aggregator/perdocexpr.cpp
+++ b/searchlib/src/tests/aggregator/perdocexpr.cpp
@@ -694,10 +694,9 @@ TEST("testDebugFunction") {
DebugWaitFunctionNode n(std::move(add), 1.3, false);
n.prepare(false);
- FastOS_Time time;
- time.SetNow();
+ fastos::StopWatch timer;
n.execute();
- EXPECT_TRUE(time.MilliSecsToNow() > 1000.0);
+ EXPECT_TRUE(timer.elapsed().ms() > 1000.0);
EXPECT_EQUAL(static_cast<const Int64ResultNode &>(n.getResult()).get(), 7);
}
{
@@ -707,10 +706,9 @@ TEST("testDebugFunction") {
DebugWaitFunctionNode n(std::move(add), 1.3, true);
n.prepare(false);
- FastOS_Time time;
- time.SetNow();
+ fastos::StopWatch timer;
n.execute();
- EXPECT_TRUE(time.MilliSecsToNow() > 1000.0);
+ EXPECT_TRUE(timer.elapsed().ms() > 1000.0);
EXPECT_EQUAL(static_cast<const Int64ResultNode &>(n.getResult()).get(), 7);
}
}
diff --git a/searchlib/src/tests/attribute/benchmark/attributesearcher.h b/searchlib/src/tests/attribute/benchmark/attributesearcher.h
index adc63266489..66bb6467194 100644
--- a/searchlib/src/tests/attribute/benchmark/attributesearcher.h
+++ b/searchlib/src/tests/attribute/benchmark/attributesearcher.h
@@ -63,7 +63,7 @@ protected:
typedef AttributeVector::SP AttributePtr;
const AttributePtr & _attrPtr;
- FastOS_Time _timer;
+ fastos::StopWatch _timer;
AttributeSearcherStatus _status;
public:
@@ -114,14 +114,14 @@ public:
{
_status._numQueries = numQueries;
}
- virtual void doRun() override;
+ void doRun() override;
};
template <typename T>
void
AttributeFindSearcher<T>::doRun()
{
- _timer.SetNow();
+ _timer.restart();
for (uint32_t i = 0; i < _status._numQueries; ++i) {
// build simple term query
vespalib::asciistream ss;
@@ -134,12 +134,12 @@ AttributeFindSearcher<T>::doRun()
attribute::SearchContextParams());
searchContext->fetchPostings(true);
- std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(NULL, true);
+ std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(nullptr, true);
std::unique_ptr<ResultSet> results = performSearch(*iterator, _attrPtr->getNumDocs());
_status._totalHitCount += results->getNumHits();
}
- _status._totalSearchTime += _timer.MilliSecsToNow();
+ _status._totalSearchTime += _timer.elapsed().ms();
}
@@ -192,13 +192,13 @@ public:
{
_status._numQueries = numQueries;
}
- virtual void doRun() override;
+ void doRun() override;
};
void
AttributeRangeSearcher::doRun()
{
- _timer.SetNow();
+ _timer.restart();
RangeIterator iter(_spec);
for (uint32_t i = 0; i < _status._numQueries; ++i, ++iter) {
// build simple range term query
@@ -212,12 +212,12 @@ AttributeRangeSearcher::doRun()
attribute::SearchContextParams());
searchContext->fetchPostings(true);
- std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(NULL, true);
+ std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(nullptr, true);
std::unique_ptr<ResultSet> results = performSearch(*iterator, _attrPtr->getNumDocs());
_status._totalHitCount += results->getNumHits();
}
- _status._totalSearchTime += _timer.MilliSecsToNow();
+ _status._totalSearchTime += _timer.elapsed().ms();
}
@@ -234,13 +234,13 @@ public:
{
_status._numQueries = numQueries;
}
- virtual void doRun() override;
+ void doRun() override;
};
void
AttributePrefixSearcher::doRun()
{
- _timer.SetNow();
+ _timer.restart();
for (uint32_t i = 0; i < _status._numQueries; ++i) {
// build simple prefix term query
buildTermQuery(_query, _attrPtr->getName(), _values[i % _values.size()].c_str(), true);
@@ -251,15 +251,12 @@ AttributePrefixSearcher::doRun()
attribute::SearchContextParams());
searchContext->fetchPostings(true);
- std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(NULL, true);
+ std::unique_ptr<queryeval::SearchIterator> iterator = searchContext->createIterator(nullptr, true);
std::unique_ptr<ResultSet> results = performSearch(*iterator, _attrPtr->getNumDocs());
_status._totalHitCount += results->getNumHits();
}
- _status._totalSearchTime += _timer.MilliSecsToNow();
+ _status._totalSearchTime += _timer.elapsed().ms();
}
-
-
} // search
-
diff --git a/searchlib/src/tests/attribute/benchmark/attributeupdater.h b/searchlib/src/tests/attribute/benchmark/attributeupdater.h
index 1dad2cb563d..c56c809457b 100644
--- a/searchlib/src/tests/attribute/benchmark/attributeupdater.h
+++ b/searchlib/src/tests/attribute/benchmark/attributeupdater.h
@@ -98,7 +98,7 @@ protected:
std::vector<BT> _getBuffer;
RandomGenerator & _rndGen;
AttributeCommit _expected;
- FastOS_Time _timer;
+ fastos::StopWatch _timer;
AttributeUpdaterStatus _status;
AttributeValidator _validator;
@@ -267,7 +267,7 @@ template <typename Vector, typename T, typename BT>
void
AttributeUpdater<Vector, T, BT>::populate()
{
- _timer.SetNow();
+ _timer.restart();
for (uint32_t doc = 0; doc < _attrPtr->getNumDocs(); ++doc) {
updateValues(doc);
if (doc % _commitFreq == (_commitFreq - 1)) {
@@ -275,7 +275,7 @@ AttributeUpdater<Vector, T, BT>::populate()
}
}
commit();
- _status._totalUpdateTime += _timer.MilliSecsToNow();
+ _status._totalUpdateTime += _timer.elapsed().ms();
}
@@ -283,7 +283,7 @@ template <typename Vector, typename T, typename BT>
void
AttributeUpdater<Vector, T, BT>::update(uint32_t numUpdates)
{
- _timer.SetNow();
+ _timer.restart();
for (uint32_t i = 0; i < numUpdates; ++i) {
uint32_t doc = getRandomDoc();
updateValues(doc);
@@ -292,7 +292,7 @@ AttributeUpdater<Vector, T, BT>::update(uint32_t numUpdates)
}
}
commit();
- _status._totalUpdateTime += _timer.MilliSecsToNow();
+ _status._totalUpdateTime += _timer.elapsed().ms();
}
@@ -300,7 +300,7 @@ template <typename Vector, typename T, typename BT>
void
AttributeUpdaterThread<Vector, T, BT>::doRun()
{
- this->_timer.SetNow();
+ this->_timer.restart();
while(!_done) {
uint32_t doc = this->getRandomDoc();
this->updateValues(doc);
@@ -309,7 +309,7 @@ AttributeUpdaterThread<Vector, T, BT>::doRun()
}
}
this->commit();
- this->_status._totalUpdateTime += this->_timer.MilliSecsToNow();
+ this->_status._totalUpdateTime += this->_timer.elapsed().ms();
}
diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp
index eb3218468ae..18bcde35020 100644
--- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp
+++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp
@@ -1,31 +1,27 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/searchlib/common/bitvector.h>
-#include <vespa/searchlib/common/resultset.h>
#include <vespa/searchlib/util/rand48.h>
#include <vespa/searchlib/test/fakedata/fakeword.h>
#include <vespa/searchlib/test/fakedata/fakewordset.h>
#include <vespa/searchlib/index/docidandfeatures.h>
#include <vespa/searchlib/index/field_length_info.h>
#include <vespa/searchlib/index/postinglisthandle.h>
-#include <vespa/searchlib/diskindex/zcposocc.h>
#include <vespa/searchlib/diskindex/zcposoccrandread.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/index/schemautil.h>
#include <vespa/searchlib/diskindex/fieldwriter.h>
#include <vespa/searchlib/diskindex/fieldreader.h>
#include <vespa/vespalib/io/fileutil.h>
-#include <vespa/searchlib/util/dirtraverse.h>
#include <vespa/searchlib/diskindex/pagedict4file.h>
#include <vespa/searchlib/diskindex/pagedict4randread.h>
#include <vespa/vespalib/stllike/asciistream.h>
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
#include <openssl/sha.h>
#include <vespa/fastos/app.h>
#include <vespa/log/log.h>
LOG_SETUP("fieldwriter_test");
-using search::ResultSet;
using search::TuneFileRandRead;
using search::TuneFileSeqRead;
using search::TuneFileSeqWrite;
@@ -362,18 +358,13 @@ writeField(FakeWordSet &wordSet,
{
const char *dynamicKStr = dynamicK ? "true" : "false";
- FastOS_Time tv;
- double before;
- double after;
-
LOG(info,
"enter writeField, "
"namepref=%s, dynamicK=%s, encode_interleaved_features=%s",
namepref.c_str(),
dynamicKStr,
bool_to_str(encode_interleaved_features));
- tv.SetNow();
- before = tv.Secs();
+ fastos::StopWatch tv;
WrappedFieldWriter ostate(namepref,
dynamicK, encode_interleaved_features,
wordSet.getNumWords(), docIdLimit);
@@ -390,8 +381,6 @@ writeField(FakeWordSet &wordSet,
}
ostate.close();
- tv.SetNow();
- after = tv.Secs();
LOG(info,
"leave writeField, "
"namepref=%s, dynamicK=%s, encode_interleaved_features=%s"
@@ -399,7 +388,7 @@ writeField(FakeWordSet &wordSet,
namepref.c_str(),
dynamicKStr,
bool_to_str(encode_interleaved_features),
- after - before);
+ tv.elapsed().sec());
}
@@ -413,19 +402,11 @@ readField(FakeWordSet &wordSet,
{
const char *dynamicKStr = dynamicK ? "true" : "false";
- FastOS_Time tv;
- double before;
- double after;
- WrappedFieldReader istate(namepref, wordSet.getNumWords(),
- docIdLimit);
- LOG(info,
- "enter readField, "
- "namepref=%s, dynamicK=%s, decode_interleaved_features=%s",
- namepref.c_str(),
- dynamicKStr,
- bool_to_str(decode_interleaved_features));
- tv.SetNow();
- before = tv.Secs();
+ WrappedFieldReader istate(namepref, wordSet.getNumWords(), docIdLimit);
+ LOG(info, "enter readField, namepref=%s, dynamicK=%s, decode_interleaved_features=%s",
+ namepref.c_str(), dynamicKStr, bool_to_str(decode_interleaved_features));
+
+ fastos::StopWatch tv;
istate.open();
if (istate._fieldReader->isValid())
istate._fieldReader->read();
@@ -448,16 +429,10 @@ readField(FakeWordSet &wordSet,
}
istate.close();
- tv.SetNow();
- after = tv.Secs();
- LOG(info,
- "leave readField, "
- "namepref=%s, dynamicK=%s, decode_interleaved_features=%s"
- " elapsed=%10.6f",
- namepref.c_str(),
- dynamicKStr,
+ LOG(info, "leave readField, namepref=%s, dynamicK=%s, decode_interleaved_features=%s elapsed=%10.6f",
+ namepref.c_str(), dynamicKStr,
bool_to_str(decode_interleaved_features),
- after - before);
+ tv.elapsed().sec());
}
@@ -470,19 +445,12 @@ randReadField(FakeWordSet &wordSet,
{
const char *dynamicKStr = dynamicK ? "true" : "false";
- FastOS_Time tv;
- double before;
- double after;
PostingListCounts counts;
- LOG(info,
- "enter randReadField,"
- " namepref=%s, dynamicK=%s, decode_interleaved_features=%s",
- namepref.c_str(),
- dynamicKStr,
- bool_to_str(decode_interleaved_features));
- tv.SetNow();
- before = tv.Secs();
+ LOG(info, "enter randReadField, namepref=%s, dynamicK=%s, decode_interleaved_features=%s",
+ namepref.c_str(), dynamicKStr, bool_to_str(decode_interleaved_features));
+
+ fastos::StopWatch tv;
std::string cname = dirprefix + namepref;
cname += "dictionary";
@@ -490,15 +458,12 @@ randReadField(FakeWordSet &wordSet,
std::unique_ptr<search::index::DictionaryFileRandRead> dictFile;
dictFile.reset(new PageDict4RandRead);
- search::index::PostingListFileRandRead *postingFile = NULL;
+ search::index::PostingListFileRandRead *postingFile = nullptr;
if (dynamicK)
- postingFile =
- new search::diskindex::ZcPosOccRandRead;
+ postingFile = new search::diskindex::ZcPosOccRandRead;
else
- postingFile =
- new search::diskindex::Zc4PosOccRandRead;
+ postingFile = new search::diskindex::Zc4PosOccRandRead;
- TuneFileSeqRead tuneFileRead;
TuneFileRandRead tuneFileRandRead;
bool openCntRes = dictFile->open(cname, tuneFileRandRead);
assert(openCntRes);
@@ -560,16 +525,11 @@ randReadField(FakeWordSet &wordSet,
dictFile->close();
delete postingFile;
dictFile.reset();
- tv.SetNow();
- after = tv.Secs();
- LOG(info,
- "leave randReadField, namepref=%s,"
- " dynamicK=%s, decode_interleaved_features=%s, "
- "elapsed=%10.6f",
+ LOG(info, "leave randReadField, namepref=%s, dynamicK=%s, decode_interleaved_features=%s, elapsed=%10.6f",
namepref.c_str(),
dynamicKStr,
bool_to_str(decode_interleaved_features),
- after - before);
+ tv.elapsed().sec());
}
@@ -595,16 +555,10 @@ fusionField(uint32_t numWordIds,
rawStr,
dynamicKStr, bool_to_str(encode_interleaved_features));
- FastOS_Time tv;
- double before;
- double after;
- WrappedFieldWriter ostate(opref,
- dynamicK, encode_interleaved_features,
- numWordIds, docIdLimit);
+ WrappedFieldWriter ostate(opref, dynamicK, encode_interleaved_features, numWordIds, docIdLimit);
WrappedFieldReader istate(ipref, numWordIds, docIdLimit);
- tv.SetNow();
- before = tv.Secs();
+ fastos::StopWatch tv;
ostate.open();
istate.open();
@@ -624,8 +578,7 @@ fusionField(uint32_t numWordIds,
}
istate.close();
ostate.close();
- tv.SetNow();
- after = tv.Secs();
+
LOG(info,
"leave fusionField, ipref=%s, opref=%s,"
" raw=%s dynamicK=%s, encode_interleaved_features=%s,"
@@ -634,7 +587,7 @@ fusionField(uint32_t numWordIds,
opref.c_str(),
rawStr,
dynamicKStr, bool_to_str(encode_interleaved_features),
- after - before);
+ tv.elapsed().sec());
}
@@ -754,7 +707,7 @@ main(int argc, char **argv)
{
fieldwriter::FieldWriterTest app;
- setvbuf(stdout, NULL, _IOLBF, 32768);
+ setvbuf(stdout, nullptr, _IOLBF, 32768);
app._rnd.srand48(32);
return app.Entry(argc, argv);
}
diff --git a/searchlib/src/tests/features/featurebenchmark.cpp b/searchlib/src/tests/features/featurebenchmark.cpp
index 2c0014e21f6..43b1e38f4a4 100644
--- a/searchlib/src/tests/features/featurebenchmark.cpp
+++ b/searchlib/src/tests/features/featurebenchmark.cpp
@@ -105,11 +105,11 @@ public:
private:
search::fef::BlueprintFactory _factory;
- FastOS_Time _timer;
- double _sample;
+ fastos::StopWatch _timer;
+ fastos::TimeStamp _sample;
- void start() { _timer.SetNow(); }
- void sample() { _sample = _timer.MilliSecsToNow(); }
+ void start() { _timer.restart(); }
+ void sample() { _sample = _timer.elapsed(); }
void setupPropertyMap(Properties & props, const KeyValueVector & values);
void runFieldMatch(Config & cfg);
void runRankingExpression(Config & cfg);
@@ -648,8 +648,8 @@ Benchmark::Main()
std::cout << "feature case '" << cfg.getCase() << "' is not known" << std::endl;
}
- std::cout << "TET: " << _sample << " (ms)" << std::endl;
- std::cout << "ETPD: " << std::fixed << std::setprecision(10) << _sample / cfg.getNumRuns() << " (ms)" << std::endl;
+ std::cout << "TET: " << _sample.ms() << " (ms)" << std::endl;
+ std::cout << "ETPD: " << std::fixed << std::setprecision(10) << _sample.ms() / cfg.getNumRuns() << " (ms)" << std::endl;
std::cout << "**** '" << cfg.getFeature() << "' ****" << std::endl;
TEST_DONE();
diff --git a/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp b/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp
index c789fb582ec..bed5d656b93 100644
--- a/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp
+++ b/searchlib/src/tests/fef/phrasesplitter/benchmark.cpp
@@ -6,7 +6,7 @@
#include <vespa/searchlib/fef/matchdatalayout.h>
#include <vespa/searchlib/fef/phrasesplitter.h>
#include <vespa/searchlib/fef/test/queryenvironment.h>
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
#include <vespa/log/log.h>
LOG_SETUP("phrasesplitter_test");
@@ -16,11 +16,11 @@ namespace search::fef {
class Benchmark : public vespalib::TestApp
{
private:
- FastOS_Time _timer;
- double _sample;
+ fastos::StopWatch _timer;
+ fastos::TimeStamp _sample;
- void start() { _timer.SetNow(); }
- void sample() { _sample = _timer.MilliSecsToNow(); }
+ void start() { _timer.restart(); }
+ void sample() { _sample = _timer.elapsed(); }
void run(size_t numRuns, size_t numPositions);
public:
@@ -69,13 +69,13 @@ Benchmark::Main()
return 0;
}
- size_t numRuns = strtoull(_argv[1], NULL, 10);
- size_t numPositions = strtoull(_argv[2], NULL, 10);
+ size_t numRuns = strtoull(_argv[1], nullptr, 10);
+ size_t numPositions = strtoull(_argv[2], nullptr, 10);
run(numRuns, numPositions);
- std::cout << "TET: " << _sample << " (ms)" << std::endl;
- std::cout << "ETPD: " << std::fixed << std::setprecision(10) << _sample / numRuns << " (ms)" << std::endl;
+ std::cout << "TET: " << _sample.ms() << " (ms)" << std::endl;
+ std::cout << "ETPD: " << std::fixed << std::setprecision(10) << _sample.ms() / numRuns << " (ms)" << std::endl;
TEST_DONE();
}
diff --git a/searchlib/src/tests/grouping/grouping_test.cpp b/searchlib/src/tests/grouping/grouping_test.cpp
index 0750d30f60d..237c8035b86 100644
--- a/searchlib/src/tests/grouping/grouping_test.cpp
+++ b/searchlib/src/tests/grouping/grouping_test.cpp
@@ -1896,12 +1896,11 @@ Test::testNanSorting()
EXPECT_FALSE(0.2 < myNan);
EXPECT_FALSE(0.2 > myNan);
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
std::vector<double> groups;
- while (timer.MilliSecsToNow() < 60000.0) {
+ while (timer.elapsed().ms() < 60000.0) {
std::vector<double> vec;
- srand((unsigned int)timer.MilliSecs());
+ srand((unsigned int)timer.elapsed().us());
size_t limit = 2345678;
size_t mod = rand() % limit;
for (size_t i = 0; i < limit; i++) {
diff --git a/searchlib/src/tests/groupingengine/groupingengine_test.cpp b/searchlib/src/tests/groupingengine/groupingengine_test.cpp
index da9b8d62305..11a661a743e 100644
--- a/searchlib/src/tests/groupingengine/groupingengine_test.cpp
+++ b/searchlib/src/tests/groupingengine/groupingengine_test.cpp
@@ -1894,12 +1894,11 @@ Test::testNanSorting()
EXPECT_FALSE(0.2 < myNan);
EXPECT_FALSE(0.2 > myNan);
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
std::vector<double> groups;
- while (timer.MilliSecsToNow() < 60000.0) {
+ while (timer.elapsed().ms()() < 60000.0) {
std::vector<double> vec;
- srand((unsigned int)timer.MilliSecs());
+ srand((unsigned int)timer.elapsed.us()());
size_t limit = 2345678;
size_t mod = rand() % limit;
for (size_t i = 0; i < limit; i++) {
diff --git a/searchlib/src/tests/postinglistbm/stress_runner.cpp b/searchlib/src/tests/postinglistbm/stress_runner.cpp
index a2a2968c13c..53b683cd7fd 100644
--- a/searchlib/src/tests/postinglistbm/stress_runner.cpp
+++ b/searchlib/src/tests/postinglistbm/stress_runner.cpp
@@ -3,16 +3,10 @@
#include "stress_runner.h"
#include <vespa/fastos/thread.h>
-#include <vespa/fastos/time.h>
-#include <vespa/searchlib/common/bitvector.h>
#include <vespa/searchlib/test/fakedata/fake_match_loop.h>
-#include <vespa/searchlib/test/fakedata/fakeegcompr64filterocc.h>
-#include <vespa/searchlib/test/fakedata/fakefilterocc.h>
#include <vespa/searchlib/test/fakedata/fakeposting.h>
#include <vespa/searchlib/test/fakedata/fakeword.h>
#include <vespa/searchlib/test/fakedata/fakewordset.h>
-#include <vespa/searchlib/test/fakedata/fakezcbfilterocc.h>
-#include <vespa/searchlib/test/fakedata/fakezcfilterocc.h>
#include <vespa/searchlib/test/fakedata/fpfactory.h>
#include <condition_variable>
#include <mutex>
@@ -236,12 +230,8 @@ StressMaster::makePostingsHelper(FPFactory *postingFactory,
const std::string &postingFormat,
bool validate, bool verbose)
{
- FastOS_Time tv;
- double before;
- double after;
+ fastos::StopWatch tv;
- tv.SetNow();
- before = tv.Secs();
postingFactory->setup(_wordSet);
for (size_t i = 0; i < _wordSet.words().size(); ++i)
makeSomePostings(postingFactory,
@@ -249,11 +239,10 @@ StressMaster::makePostingsHelper(FPFactory *postingFactory,
_stride,
validate,
verbose);
- tv.SetNow();
- after = tv.Secs();
+
LOG(info,
"StressMaster::makePostingsHelper() elapsed %10.6f s for %s format",
- after - before,
+ tv.elapsed().sec(),
postingFormat.c_str());
}
@@ -323,12 +312,8 @@ StressMaster::run()
double
StressMaster::runWorkers(const std::string &postingFormat)
{
- FastOS_Time tv;
- double before;
- double after;
+ fastos::StopWatch tv;
- tv.SetNow();
- before = tv.Secs();
uint32_t numWorkers = 8;
for (uint32_t i = 0; i < numWorkers; ++i) {
if (_operatorType == StressRunner::OperatorType::Direct) {
@@ -350,15 +335,14 @@ StressMaster::runWorkers(const std::string &postingFormat)
_taskCond.wait(taskGuard);
}
}
- tv.SetNow();
- after = tv.Secs();
+
LOG(info,
"StressMaster::run() elapsed %10.6f s for workers %s format",
- after - before,
+ tv.elapsed().sec(),
postingFormat.c_str());
_workers.clear();
_workersDone = 0;
- return after - before;
+ return tv.elapsed().sec();
}
StressWorker::StressWorker(StressMaster& master, uint32_t id)
diff --git a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp
index 38d6483f21a..7d2efc5f2bc 100644
--- a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp
+++ b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp
@@ -9,7 +9,6 @@
#include <vespa/searchlib/queryeval/andnotsearch.h>
#include <vespa/searchlib/queryeval/andsearch.h>
#include <vespa/searchlib/queryeval/dot_product_search.h>
-#include <vespa/searchlib/queryeval/fake_search.h>
#include <vespa/searchlib/util/rand48.h>
#include <vespa/searchlib/queryeval/orsearch.h>
#include <vespa/searchlib/queryeval/simpleresult.h>
@@ -334,13 +333,12 @@ Result run_single_benchmark(FilterStrategy &filterStrategy, SparseVectorFactory
SearchIterator::UP search(filterStrategy.createRoot(vectorFactory, childFactory, childCnt, limit));
SearchIterator &sb = *search;
uint32_t num_hits = 0;
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
for (sb.seek(1); !sb.isAtEnd(); sb.seek(sb.getDocId() + 1)) {
++num_hits;
sb.unpack(sb.getDocId());
}
- return Result(timer.MilliSecsToNow(), num_hits);
+ return Result(timer.elapsed().ms(), num_hits);
}
//-----------------------------------------------------------------------------
diff --git a/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp b/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp
index 42df9fb0091..65890f81e16 100644
--- a/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp
+++ b/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp
@@ -195,13 +195,12 @@ struct Setup {
void perform() {
SearchIterator::UP search = create();
SearchIterator &sb = *search;
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
for (sb.seek(1); !sb.isAtEnd(); sb.seek(sb.getDocId() + 1)) {
stats.hit();
sb.unpack(sb.getDocId());
}
- double ms = timer.MilliSecsToNow();
+ double ms = timer.elapsed().ms();
if (ms < minTimeMs) {
minTimeMs = ms;
}
diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp
index 65c4cd7da95..640e6f45e80 100644
--- a/searchlib/src/tests/sortspec/multilevelsort.cpp
+++ b/searchlib/src/tests/sortspec/multilevelsort.cpp
@@ -263,10 +263,9 @@ MultilevelSortTest::sortAndCheck(const std::vector<Spec> &spec, uint32_t num,
}
}
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
sorter.sortResults(hits, num, num);
- LOG(info, "sort time = %f ms", timer.MilliSecsToNow());
+ LOG(info, "sort time = %ld ms", timer.elapsed().ms());
uint32_t *offsets = new uint32_t[num + 1];
char *buf = new char[sorter.getSortDataSize(0, num)];
diff --git a/searchlib/src/tests/transactionlogstress/translogstress.cpp b/searchlib/src/tests/transactionlogstress/translogstress.cpp
index 095cc29984b..a047c5e1657 100644
--- a/searchlib/src/tests/transactionlogstress/translogstress.cpp
+++ b/searchlib/src/tests/transactionlogstress/translogstress.cpp
@@ -7,7 +7,7 @@
#include <vespa/searchlib/util/runnable.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/fastos/app.h>
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
#include <iostream>
#include <stdexcept>
#include <sstream>
@@ -199,7 +199,7 @@ private:
Packet _packet;
SerialNum _current;
SerialNum _lastCommited;
- FastOS_Time _timer;
+ fastos::StopWatch _timer;
void commitPacket();
bool addEntry(const Packet::Entry & e);
@@ -208,7 +208,7 @@ public:
FeederThread(const std::string & tlsSpec, const std::string & domain,
const EntryGenerator & generator, uint32_t feedRate, size_t packetSize);
~FeederThread();
- virtual void doRun() override;
+ void doRun() override;
SerialNumRange getRange() const { return SerialNumRange(1, _lastCommited); }
};
@@ -217,7 +217,7 @@ FeederThread::FeederThread(const std::string & tlsSpec, const std::string & doma
: _tlsSpec(tlsSpec), _domain(domain), _client(tlsSpec), _session(),
_generator(generator), _feedRate(feedRate), _packet(packetSize), _current(1), _lastCommited(1), _timer()
{}
-FeederThread::~FeederThread() {}
+FeederThread::~FeederThread() = default;
void
FeederThread::commitPacket()
@@ -251,7 +251,7 @@ FeederThread::doRun()
while (!_done) {
if (_feedRate != 0) {
- _timer.SetNow();
+ _timer.restart();
for (uint32_t i = 0; i < _feedRate; ++i) {
Packet::Entry entry = _generator.getRandomEntry(_current++);
if (!addEntry(entry)) {
@@ -264,7 +264,7 @@ FeederThread::doRun()
}
commitPacket();
- uint64_t milliSecsUsed = static_cast<uint64_t>(_timer.MilliSecsToNow());
+ int64_t milliSecsUsed = _timer.elapsed().ms();
if (milliSecsUsed < 1000) {
//LOG(info, "FeederThread: sleep %u ms", 1000 - milliSecsUsed);
FastOS_Thread::Sleep(1000 - milliSecsUsed);
@@ -395,7 +395,7 @@ VisitorAgent::start(SerialNum from, SerialNum to)
_to = to;
_next = from + 1;
_visitor = _client.createVisitor(_domain, *this);
- if (_visitor.get() == NULL) {
+ if ( ! _visitor) {
throw std::runtime_error(vespalib::make_string
("VisitorAgent[%u]: Could not open visitor to %s", _id, _tlsSpec.c_str()));
}
@@ -458,8 +458,8 @@ private:
std::vector<std::shared_ptr<VisitorAgent> > _visitors;
std::vector<std::shared_ptr<VisitorAgent> > _rndVisitors;
uint64_t _visitorInterval; // in milliseconds
- uint64_t _pruneInterval; // in milliseconds
- FastOS_Time _pruneTimer;
+ int64_t _pruneInterval; // in milliseconds
+ fastos::StopWatch _pruneTimer;
SerialNum _begin;
SerialNum _end;
size_t _count;
@@ -518,7 +518,7 @@ ControllerThread::doRun()
throw std::runtime_error(vespalib::make_string("ControllerThread: Could not open session to %s", _tlsSpec.c_str()));
}
- _pruneTimer.SetNow();
+ _pruneTimer.restart();
while (!_done) {
// set finished visitors as idle
for (size_t i = 0; i < _visitors.size(); ++i) {
@@ -538,7 +538,7 @@ ControllerThread::doRun()
}
}
// prune transaction log server
- if (_pruneTimer.MilliSecsToNow() > _pruneInterval) {
+ if (_pruneTimer.elapsed().ms() > _pruneInterval) {
getStatus();
SerialNum safePrune = _end;
for (size_t i = 0; i < _visitors.size(); ++i) {
@@ -551,7 +551,7 @@ ControllerThread::doRun()
if (!_session->erase(safePrune)) {
throw std::runtime_error(vespalib::make_string("ControllerThread: Could not erase up to %" PRIu64, safePrune));
}
- _pruneTimer.SetNow();
+ _pruneTimer.restart();
}
FastOS_Thread::Sleep(_visitorInterval);
}