From cf3b20dba22718b533eac6854cde86b6538958af Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 19 Nov 2019 23:22:55 +0000 Subject: FastOS_Time -> std::chrono. --- searchlib/src/tests/aggregator/perdocexpr.cpp | 10 +-- .../tests/attribute/benchmark/attributesearcher.h | 29 +++---- .../tests/attribute/benchmark/attributeupdater.h | 14 ++-- .../diskindex/fieldwriter/fieldwriter_test.cpp | 97 ++++++---------------- searchlib/src/tests/features/featurebenchmark.cpp | 12 +-- .../src/tests/fef/phrasesplitter/benchmark.cpp | 18 ++-- searchlib/src/tests/grouping/grouping_test.cpp | 7 +- .../tests/groupingengine/groupingengine_test.cpp | 7 +- .../src/tests/postinglistbm/stress_runner.cpp | 30 ++----- .../sparse_vector_benchmark_test.cpp | 6 +- .../tests/queryeval/weak_and/wand_bench_setup.hpp | 5 +- searchlib/src/tests/sortspec/multilevelsort.cpp | 5 +- .../tests/transactionlogstress/translogstress.cpp | 24 +++--- .../vespa/searchlib/attribute/attributevector.h | 2 +- .../features/random_normal_stable_feature.cpp | 1 - .../vespa/searchlib/test/fakedata/fakewordset.cpp | 15 ++-- 16 files changed, 101 insertions(+), 181 deletions(-) (limited to 'searchlib/src') 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(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(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 void AttributeFindSearcher::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::doRun() attribute::SearchContextParams()); searchContext->fetchPostings(true); - std::unique_ptr iterator = searchContext->createIterator(NULL, true); + std::unique_ptr iterator = searchContext->createIterator(nullptr, true); std::unique_ptr 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 iterator = searchContext->createIterator(NULL, true); + std::unique_ptr iterator = searchContext->createIterator(nullptr, true); std::unique_ptr 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 iterator = searchContext->createIterator(NULL, true); + std::unique_ptr iterator = searchContext->createIterator(nullptr, true); std::unique_ptr 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 _getBuffer; RandomGenerator & _rndGen; AttributeCommit _expected; - FastOS_Time _timer; + fastos::StopWatch _timer; AttributeUpdaterStatus _status; AttributeValidator _validator; @@ -267,7 +267,7 @@ template void AttributeUpdater::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::populate() } } commit(); - _status._totalUpdateTime += _timer.MilliSecsToNow(); + _status._totalUpdateTime += _timer.elapsed().ms(); } @@ -283,7 +283,7 @@ template void AttributeUpdater::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::update(uint32_t numUpdates) } } commit(); - _status._totalUpdateTime += _timer.MilliSecsToNow(); + _status._totalUpdateTime += _timer.elapsed().ms(); } @@ -300,7 +300,7 @@ template void AttributeUpdaterThread::doRun() { - this->_timer.SetNow(); + this->_timer.restart(); while(!_done) { uint32_t doc = this->getRandomDoc(); this->updateValues(doc); @@ -309,7 +309,7 @@ AttributeUpdaterThread::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 -#include #include #include #include #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include -#include +#include #include #include #include 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 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 #include #include -#include +#include #include 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 groups; - while (timer.MilliSecsToNow() < 60000.0) { + while (timer.elapsed().ms() < 60000.0) { std::vector 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 groups; - while (timer.MilliSecsToNow() < 60000.0) { + while (timer.elapsed().ms()() < 60000.0) { std::vector 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 -#include -#include #include -#include -#include #include #include #include -#include -#include #include #include #include @@ -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 #include #include -#include #include #include #include @@ -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, 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 #include #include -#include +#include #include #include #include @@ -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(_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 > _visitors; std::vector > _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); } diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index 99fd5a88e48..39423ef74c4 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp index 5e93173abac..bde0cedaed0 100644 --- a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp @@ -3,7 +3,6 @@ #include "random_normal_stable_feature.h" #include "utils.h" #include -#include #include LOG_SETUP(".features.randomnormalstablefeature"); diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp index 1be2ea65796..1eec8261bf8 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp @@ -2,7 +2,7 @@ #include "fakewordset.h" #include "fakeword.h" -#include +#include #include #include @@ -96,15 +96,11 @@ FakeWordSet::setupWords(search::Rand48 &rnd, std::string common = "common"; std::string medium = "medium"; std::string rare = "rare"; - FastOS_Time tv; - double before; - double after; - _numDocs = numDocs; LOG(info, "enter setupWords"); - tv.SetNow(); - before = tv.Secs(); + fastos::StopWatch tv; + uint32_t packedIndex = _fieldsParams.size() - 1; for (uint32_t i = 0; i < numWordsPerWordClass; ++i) { std::ostringstream vi; @@ -125,9 +121,8 @@ FakeWordSet::setupWords(search::Rand48 &rnd, _fieldsParams[packedIndex], packedIndex)); } - tv.SetNow(); - after = tv.Secs(); - LOG(info, "leave setupWords, elapsed %10.6f s", after - before); + + LOG(info, "leave setupWords, elapsed %10.6f s", tv.elapsed().sec()); } int -- cgit v1.2.3