diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-16 22:55:04 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-16 22:55:04 -0600 |
commit | 06eae17d656fd281e05ca28d4e38696fc05d2dbf (patch) | |
tree | 3cd1f386e75cfdefaedb1ba19f8fbdc5533fc5b7 /searchlib/src/tests | |
parent | 72e3bfb3c55653e57991ba3aff1f58f25f20dd8b (diff) |
Revert "Revert "Balder/remove steadytimestamp 2""
Diffstat (limited to 'searchlib/src/tests')
10 files changed, 68 insertions, 69 deletions
diff --git a/searchlib/src/tests/aggregator/perdocexpr.cpp b/searchlib/src/tests/aggregator/perdocexpr.cpp index c078282c442..513e94321e1 100644 --- a/searchlib/src/tests/aggregator/perdocexpr.cpp +++ b/searchlib/src/tests/aggregator/perdocexpr.cpp @@ -694,9 +694,9 @@ TEST("testDebugFunction") { DebugWaitFunctionNode n(std::move(add), 1.3, false); n.prepare(false); - fastos::StopWatch timer; + vespalib::Timer timer; n.execute(); - EXPECT_TRUE(timer.elapsed().ms() > 1000.0); + EXPECT_TRUE(timer.elapsed() > 1s); EXPECT_EQUAL(static_cast<const Int64ResultNode &>(n.getResult()).get(), 7); } { @@ -706,9 +706,9 @@ TEST("testDebugFunction") { DebugWaitFunctionNode n(std::move(add), 1.3, true); n.prepare(false); - fastos::StopWatch timer; + vespalib::Timer timer; n.execute(); - EXPECT_TRUE(timer.elapsed().ms() > 1000.0); + EXPECT_TRUE(timer.elapsed() > 1s); 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 66bb6467194..8ff6ba46e86 100644 --- a/searchlib/src/tests/attribute/benchmark/attributesearcher.h +++ b/searchlib/src/tests/attribute/benchmark/attributesearcher.h @@ -26,7 +26,7 @@ performSearch(queryeval::SearchIterator & sb, uint32_t numDocs) class AttributeSearcherStatus { public: - double _totalSearchTime; + vespalib::duration _totalSearchTime; uint64_t _totalHitCount; uint64_t _numQueries; uint64_t _numClients; @@ -39,20 +39,20 @@ public: _numClients += status._numClients; } void printXML() const { - std::cout << "<total-search-time>" << _totalSearchTime << "</total-search-time>" << std::endl; // ms + std::cout << "<total-search-time>" << vespalib::count_ms(_totalSearchTime) << "</total-search-time>" << std::endl; // ms std::cout << "<avg-search-time>" << avgSearchTime() << "</avg-search-time>" << std::endl; // ms std::cout << "<search-throughput>" << searchThroughout() << "</search-throughput>" << std::endl; // per/sec std::cout << "<total-hit-count>" << _totalHitCount << "</total-hit-count>" << std::endl; std::cout << "<avg-hit-count>" << avgHitCount() << "</avg-hit-count>" << std::endl; } double avgSearchTime() const { - return _totalSearchTime / _numQueries; + return vespalib::count_ms(_totalSearchTime/_numQueries); } double searchThroughout() const { - return _numClients * 1000 * _numQueries / _totalSearchTime; + return _numClients * 1000 * _numQueries / (vespalib::count_ns(_totalSearchTime)/1000000.0); } double avgHitCount() const { - return _totalHitCount / static_cast<double>(_numQueries); + return _totalHitCount / double(_numQueries); } }; @@ -62,8 +62,8 @@ class AttributeSearcher : public Runnable protected: typedef AttributeVector::SP AttributePtr; - const AttributePtr & _attrPtr; - fastos::StopWatch _timer; + const AttributePtr & _attrPtr; + vespalib::Timer _timer; AttributeSearcherStatus _status; public: @@ -121,7 +121,7 @@ template <typename T> void AttributeFindSearcher<T>::doRun() { - _timer.restart(); + _timer = vespalib::Timer(); for (uint32_t i = 0; i < _status._numQueries; ++i) { // build simple term query vespalib::asciistream ss; @@ -139,7 +139,7 @@ AttributeFindSearcher<T>::doRun() _status._totalHitCount += results->getNumHits(); } - _status._totalSearchTime += _timer.elapsed().ms(); + _status._totalSearchTime += _timer.elapsed(); } @@ -198,7 +198,7 @@ public: void AttributeRangeSearcher::doRun() { - _timer.restart(); + _timer = vespalib::Timer(); RangeIterator iter(_spec); for (uint32_t i = 0; i < _status._numQueries; ++i, ++iter) { // build simple range term query @@ -217,7 +217,7 @@ AttributeRangeSearcher::doRun() _status._totalHitCount += results->getNumHits(); } - _status._totalSearchTime += _timer.elapsed().ms(); + _status._totalSearchTime += _timer.elapsed(); } @@ -240,7 +240,7 @@ public: void AttributePrefixSearcher::doRun() { - _timer.restart(); + _timer = vespalib::Timer(); 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); @@ -256,7 +256,7 @@ AttributePrefixSearcher::doRun() _status._totalHitCount += results->getNumHits(); } - _status._totalSearchTime += _timer.elapsed().ms(); + _status._totalSearchTime += _timer.elapsed(); } } // search diff --git a/searchlib/src/tests/attribute/benchmark/attributeupdater.h b/searchlib/src/tests/attribute/benchmark/attributeupdater.h index c56c809457b..e4cfaf430d8 100644 --- a/searchlib/src/tests/attribute/benchmark/attributeupdater.h +++ b/searchlib/src/tests/attribute/benchmark/attributeupdater.h @@ -49,19 +49,19 @@ public: class AttributeUpdaterStatus { public: - double _totalUpdateTime; + vespalib::duration _totalUpdateTime; uint64_t _numDocumentUpdates; uint64_t _numValueUpdates; AttributeUpdaterStatus() : - _totalUpdateTime(0), _numDocumentUpdates(0), _numValueUpdates(0) {} + _totalUpdateTime(vespalib::duration::zero()), _numDocumentUpdates(0), _numValueUpdates(0) {} void reset() { - _totalUpdateTime = 0; + _totalUpdateTime = vespalib::duration::zero(); _numDocumentUpdates = 0; _numValueUpdates = 0; } void printXML() const { - std::cout << "<total-update-time>" << _totalUpdateTime << "</total-update-time>" << std::endl; + std::cout << "<total-update-time>" << vespalib::count_ms(_totalUpdateTime) << "</total-update-time>" << std::endl; std::cout << "<documents-updated>" << _numDocumentUpdates << "</documents-updated>" << std::endl; std::cout << "<document-update-throughput>" << documentUpdateThroughput() << "</document-update-throughput>" << std::endl; std::cout << "<avg-document-update-time>" << avgDocumentUpdateTime() << "</avg-document-update-time>" << std::endl; @@ -70,17 +70,19 @@ public: std::cout << "<avg-value-update-time>" << avgValueUpdateTime() << "</avg-value-update-time>" << std::endl; } double documentUpdateThroughput() const { - return _numDocumentUpdates * 1000 / _totalUpdateTime; + return _numDocumentUpdates * 1000 / as_ms(); } double avgDocumentUpdateTime() const { - return _totalUpdateTime / _numDocumentUpdates; + return vespalib::count_ms(_totalUpdateTime / _numDocumentUpdates); } double valueUpdateThroughput() const { - return _numValueUpdates * 1000 / _totalUpdateTime; + return _numValueUpdates * 1000 / as_ms(); } double avgValueUpdateTime() const { - return _totalUpdateTime / _numValueUpdates; + return vespalib::count_ms(_totalUpdateTime / _numValueUpdates); } +private: + double as_ms() const { return vespalib::count_ns(_totalUpdateTime)/1000000.0;} }; // AttributeVectorInstance, AttributeVectorType, AttributeVectorBufferType @@ -98,7 +100,7 @@ protected: std::vector<BT> _getBuffer; RandomGenerator & _rndGen; AttributeCommit _expected; - fastos::StopWatch _timer; + vespalib::Timer _timer; AttributeUpdaterStatus _status; AttributeValidator _validator; @@ -148,7 +150,7 @@ AttributeUpdater<Vector, T, BT>::AttributeUpdater(const AttributePtr & attrPtr, {} template <typename Vector, typename T, typename BT> -AttributeUpdater<Vector, T, BT>::~AttributeUpdater() {} +AttributeUpdater<Vector, T, BT>::~AttributeUpdater() = default; template <typename Vector, typename T, typename BT> class AttributeUpdaterThread : public AttributeUpdater<Vector, T, BT>, public Runnable @@ -173,7 +175,7 @@ AttributeUpdaterThread<Vector, T, BT>::AttributeUpdaterThread(const AttributePtr Runnable() {} template <typename Vector, typename T, typename BT> -AttributeUpdaterThread<Vector, T, BT>::~AttributeUpdaterThread() { } +AttributeUpdaterThread<Vector, T, BT>::~AttributeUpdaterThread() = default; template <typename Vector, typename T, typename BT> @@ -267,7 +269,7 @@ template <typename Vector, typename T, typename BT> void AttributeUpdater<Vector, T, BT>::populate() { - _timer.restart(); + _timer = vespalib::Timer(); for (uint32_t doc = 0; doc < _attrPtr->getNumDocs(); ++doc) { updateValues(doc); if (doc % _commitFreq == (_commitFreq - 1)) { @@ -275,7 +277,7 @@ AttributeUpdater<Vector, T, BT>::populate() } } commit(); - _status._totalUpdateTime += _timer.elapsed().ms(); + _status._totalUpdateTime += _timer.elapsed(); } @@ -283,7 +285,7 @@ template <typename Vector, typename T, typename BT> void AttributeUpdater<Vector, T, BT>::update(uint32_t numUpdates) { - _timer.restart(); + _timer = vespalib::Timer(); for (uint32_t i = 0; i < numUpdates; ++i) { uint32_t doc = getRandomDoc(); updateValues(doc); @@ -292,7 +294,7 @@ AttributeUpdater<Vector, T, BT>::update(uint32_t numUpdates) } } commit(); - _status._totalUpdateTime += _timer.elapsed().ms(); + _status._totalUpdateTime += _timer.elapsed(); } @@ -300,7 +302,7 @@ template <typename Vector, typename T, typename BT> void AttributeUpdaterThread<Vector, T, BT>::doRun() { - this->_timer.restart(); + this->_timer = vespalib::Timer(); while(!_done) { uint32_t doc = this->getRandomDoc(); this->updateValues(doc); @@ -309,9 +311,7 @@ AttributeUpdaterThread<Vector, T, BT>::doRun() } } this->commit(); - this->_status._totalUpdateTime += this->_timer.elapsed().ms(); + this->_status._totalUpdateTime += this->_timer.elapsed(); } - } // search - diff --git a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp index 7526326b6ca..3e129457d46 100644 --- a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp +++ b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp @@ -46,7 +46,7 @@ TEST_F(SearchRequestTest, require_that_hits_is_converted) { TEST_F(SearchRequestTest, require_that_timeout_is_converted) { proto.set_timeout(500); convert(); - EXPECT_EQ(request.getTimeout().ms(), 500); + EXPECT_EQ(request.getTimeout(), 500ms); } TEST_F(SearchRequestTest, require_that_trace_level_is_converted) { @@ -317,7 +317,7 @@ TEST_F(DocsumRequestTest, require_that_root_slime_is_used) { TEST_F(DocsumRequestTest, require_that_timeout_is_converted) { proto.set_timeout(500); convert(); - EXPECT_EQ(request.getTimeout().ms(), 500); + EXPECT_EQ(request.getTimeout(), 500ms); } TEST_F(DocsumRequestTest, require_that_session_key_is_converted) { diff --git a/searchlib/src/tests/features/featurebenchmark.cpp b/searchlib/src/tests/features/featurebenchmark.cpp index 43b1e38f4a4..6e1c5b1487c 100644 --- a/searchlib/src/tests/features/featurebenchmark.cpp +++ b/searchlib/src/tests/features/featurebenchmark.cpp @@ -105,10 +105,10 @@ public: private: search::fef::BlueprintFactory _factory; - fastos::StopWatch _timer; - fastos::TimeStamp _sample; + vespalib::Timer _timer; + vespalib::duration _sample; - void start() { _timer.restart(); } + void start() { _timer = vespalib::Timer(); } void sample() { _sample = _timer.elapsed(); } void setupPropertyMap(Properties & props, const KeyValueVector & values); void runFieldMatch(Config & cfg); @@ -648,8 +648,8 @@ Benchmark::Main() std::cout << "feature case '" << cfg.getCase() << "' is not known" << 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 << "TET: " << vespalib::count_ms(_sample) << " (ms)" << std::endl; + std::cout << "ETPD: " << std::fixed << std::setprecision(10) << double(vespalib::count_ms(_sample)) / cfg.getNumRuns() << " (ms)" << std::endl; std::cout << "**** '" << cfg.getFeature() << "' ****" << std::endl; TEST_DONE(); diff --git a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp index 8f22ab87c97..36a567e5675 100644 --- a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp +++ b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp @@ -277,7 +277,7 @@ Test::Main() LOG(info, "sizeof(CountAggregationResult) = %ld", sizeof(CountAggregationResult)); LOG(info, "sizeof(Int64ResultNode) = %ld", sizeof(Int64ResultNode)); - fastos::SteadyTimeStamp start(fastos::ClockSteady::now()); + vespalib::steady_time start(vespalib::steady_clock::now()); if (idType == "int") { if (aggrType == "sum") { benchmarkIntegerSum(useEngine, numDocs, numQueries, maxGroups); diff --git a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp index bf1b5352778..0743ac8408d 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp +++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp @@ -170,7 +170,7 @@ public: }; PhraseSearchTest::PhraseSearchTest(bool expiredDoom) - : _requestContext(nullptr, expiredDoom ? fastos::SteadyTimeStamp::ZERO : fastos::SteadyTimeStamp::FUTURE), + : _requestContext(nullptr, expiredDoom ? vespalib::steady_time(): vespalib::steady_time::max()), _index(), _phrase_fs(field, fieldId, phrase_handle), _phrase(_phrase_fs, _requestContext, false), @@ -199,7 +199,7 @@ void Test::requireThatIteratorHonorsFutureDoom() { test.fetchPostings(false); vespalib::Clock clock; - vespalib::Doom futureDoom(clock, fastos::SteadyTimeStamp::FUTURE); + vespalib::Doom futureDoom(clock, vespalib::steady_time::max()); unique_ptr<SearchIterator> search(test.createSearch(false)); static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom); EXPECT_TRUE(!search->seek(1u)); @@ -213,7 +213,7 @@ void Test::requireThatIteratorHonorsDoom() { test.fetchPostings(false); vespalib::Clock clock; - vespalib::Doom futureDoom(clock, fastos::SteadyTimeStamp::ZERO); + vespalib::Doom futureDoom(clock, vespalib::steady_time()); unique_ptr<SearchIterator> search(test.createSearch(false)); static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom); EXPECT_TRUE(!search->seek(1u)); 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 7d2efc5f2bc..3b61aaaac3e 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 @@ -131,8 +131,8 @@ int Plot::_plots = 0; //----------------------------------------------------------------------------- -uint32_t default_weight = 100; -double max_time = 1000000.0; +constexpr uint32_t default_weight = 100; +constexpr vespalib::duration max_time = 1000s; //----------------------------------------------------------------------------- @@ -312,20 +312,20 @@ struct NegativeFilterAfterStrategy : FilterStrategy { //----------------------------------------------------------------------------- struct Result { - double time_ms; + vespalib::duration time; uint32_t num_hits; - Result() : time_ms(max_time), num_hits(0) {} - Result(double t, uint32_t n) : time_ms(t), num_hits(n) {} + Result() : time(max_time), num_hits(0) {} + Result(vespalib::duration t, uint32_t n) : time(t), num_hits(n) {} void combine(const Result &r) { - if (time_ms == max_time) { + if (time == max_time) { *this = r; } else { assert(num_hits == r.num_hits); - time_ms = std::min(time_ms, r.time_ms); + time = std::min(time, r.time); } } std::string toString() const { - return vespalib::make_string("%u hits, %g ms", num_hits, time_ms); + return vespalib::make_string("%u hits, %ld ms", num_hits, vespalib::count_ms(time)); } }; @@ -333,12 +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::StopWatch timer; + vespalib::Timer timer; for (sb.seek(1); !sb.isAtEnd(); sb.seek(sb.getDocId() + 1)) { ++num_hits; sb.unpack(sb.getDocId()); } - return Result(timer.elapsed().ms(), num_hits); + return Result(timer.elapsed(), num_hits); } //----------------------------------------------------------------------------- @@ -371,7 +371,7 @@ public: for (int j = 0; j < 5; ++j) { result.combine(run_single_benchmark(_filterStrategy, svf, _childFactory, childCnt, _limit)); } - graph->addValue(childCnt, result.time_ms); + graph->addValue(childCnt, vespalib::count_ms(result.time)); fprintf(stderr, " %u children => %s\n", childCnt, result.toString().c_str()); } } 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 65890f81e16..576c9abe249 100644 --- a/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp +++ b/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp @@ -187,22 +187,21 @@ struct FilterFactory : WandFactory { struct Setup { Stats stats; - double minTimeMs; - Setup() : stats(), minTimeMs(10000000.0) {} + vespalib::duration minTime; + Setup() : stats(), minTime(10000s) {} virtual ~Setup() {} virtual std::string name() const = 0; virtual SearchIterator::UP create() = 0; void perform() { SearchIterator::UP search = create(); SearchIterator &sb = *search; - fastos::StopWatch timer; + vespalib::Timer timer; for (sb.seek(1); !sb.isAtEnd(); sb.seek(sb.getDocId() + 1)) { stats.hit(); sb.unpack(sb.getDocId()); } - double ms = timer.elapsed().ms(); - if (ms < minTimeMs) { - minTimeMs = ms; + if (timer.elapsed() < minTime) { + minTime = timer.elapsed(); } } void benchmark() { @@ -213,7 +212,7 @@ struct Setup { stats.print(); } } - fprintf(stderr, "time (ms): %g\n", minTimeMs); + fprintf(stderr, "time (ms): %ld\n", vespalib::count_ms(minTime)); } }; diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp index 640e6f45e80..8c4b931a265 100644 --- a/searchlib/src/tests/sortspec/multilevelsort.cpp +++ b/searchlib/src/tests/sortspec/multilevelsort.cpp @@ -241,7 +241,7 @@ MultilevelSortTest::sortAndCheck(const std::vector<Spec> &spec, uint32_t num, } vespalib::Clock clock; - vespalib::Doom doom(clock, fastos::SteadyTimeStamp::FUTURE); + vespalib::Doom doom(clock, vespalib::steady_time::max()); search::uca::UcaConverterFactory ucaFactory; FastS_SortSpec sorter(7, doom, ucaFactory, _sortMethod); // init sorter with sort data @@ -263,9 +263,9 @@ MultilevelSortTest::sortAndCheck(const std::vector<Spec> &spec, uint32_t num, } } - fastos::StopWatch timer; + vespalib::Timer timer; sorter.sortResults(hits, num, num); - LOG(info, "sort time = %ld ms", timer.elapsed().ms()); + LOG(info, "sort time = %ld ms", vespalib::count_ms(timer.elapsed())); uint32_t *offsets = new uint32_t[num + 1]; char *buf = new char[sorter.getSortDataSize(0, num)]; @@ -398,7 +398,7 @@ TEST("require that all sort methods behave the same") TEST("test that [docid] translates to [lid][paritionid]") { vespalib::Clock clock; - vespalib::Doom doom(clock, fastos::SteadyTimeStamp::FUTURE); + vespalib::Doom doom(clock, vespalib::steady_time::max()); search::uca::UcaConverterFactory ucaFactory; FastS_SortSpec asc(7, doom, ucaFactory); RankedHit hits[2] = {RankedHit(91, 0.0), RankedHit(3, 2.0)}; |