From 08fb72c58d39698d15ee7e3a0b967accbaa8bd5b Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 16 Dec 2019 23:18:41 +0000 Subject: Convert to double before computations. --- .../tests/attribute/benchmark/attributeupdater.h | 16 +++++++-------- searchlib/src/tests/features/featurebenchmark.cpp | 2 +- .../src/tests/clock/clock_benchmark.cpp | 2 +- staging_vespalib/src/tests/rusage/rusage_test.cpp | 24 ++++------------------ 4 files changed, 14 insertions(+), 30 deletions(-) diff --git a/searchlib/src/tests/attribute/benchmark/attributeupdater.h b/searchlib/src/tests/attribute/benchmark/attributeupdater.h index 3ed26c31ecb..28ecf72dd0a 100644 --- a/searchlib/src/tests/attribute/benchmark/attributeupdater.h +++ b/searchlib/src/tests/attribute/benchmark/attributeupdater.h @@ -70,17 +70,19 @@ public: std::cout << "" << avgValueUpdateTime() << "" << std::endl; } double documentUpdateThroughput() const { - return _numDocumentUpdates * 1000 / vespalib::count_ms(_totalUpdateTime); + return _numDocumentUpdates * 1000 / as_ms(); } double avgDocumentUpdateTime() const { - return vespalib::count_ms(_totalUpdateTime) / _numDocumentUpdates; + return as_ms() / _numDocumentUpdates; } double valueUpdateThroughput() const { - return _numValueUpdates * 1000 / vespalib::count_ms(_totalUpdateTime); + return _numValueUpdates * 1000 / as_ms(); } double avgValueUpdateTime() const { - return vespalib::count_ms(_totalUpdateTime) / _numValueUpdates; + return as_ms() / _numValueUpdates; } +private: + double as_ms() const { return vespalib::count_ms(_totalUpdateTime);} }; // AttributeVectorInstance, AttributeVectorType, AttributeVectorBufferType @@ -148,7 +150,7 @@ AttributeUpdater::AttributeUpdater(const AttributePtr & attrPtr, {} template -AttributeUpdater::~AttributeUpdater() {} +AttributeUpdater::~AttributeUpdater() = default; template class AttributeUpdaterThread : public AttributeUpdater, public Runnable @@ -173,7 +175,7 @@ AttributeUpdaterThread::AttributeUpdaterThread(const AttributePtr Runnable() {} template -AttributeUpdaterThread::~AttributeUpdaterThread() { } +AttributeUpdaterThread::~AttributeUpdaterThread() = default; template @@ -312,6 +314,4 @@ AttributeUpdaterThread::doRun() this->_status._totalUpdateTime += this->_timer.elapsed(); } - } // search - diff --git a/searchlib/src/tests/features/featurebenchmark.cpp b/searchlib/src/tests/features/featurebenchmark.cpp index 54c2e8c7033..6e1c5b1487c 100644 --- a/searchlib/src/tests/features/featurebenchmark.cpp +++ b/searchlib/src/tests/features/featurebenchmark.cpp @@ -649,7 +649,7 @@ Benchmark::Main() } std::cout << "TET: " << vespalib::count_ms(_sample) << " (ms)" << std::endl; - std::cout << "ETPD: " << std::fixed << std::setprecision(10) << vespalib::count_ms(_sample) / cfg.getNumRuns() << " (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/staging_vespalib/src/tests/clock/clock_benchmark.cpp b/staging_vespalib/src/tests/clock/clock_benchmark.cpp index 1a4cb20e338..cbf7275f06e 100644 --- a/staging_vespalib/src/tests/clock/clock_benchmark.cpp +++ b/staging_vespalib/src/tests/clock/clock_benchmark.cpp @@ -123,7 +123,7 @@ void benchmark(const char * desc, FastOS_ThreadPool & pool, uint64_t samples, ui count[i] += sampler->_count[i]; } } - printf("%s: Took %ld clock samples in %2.3f with [%ld, %ld, %ld] counts\n", desc, samples, to_s(steady_clock ::now() - start), count[0], count[1], count[2]); + printf("%s: Took %ld clock samples in %2.3f with [%ld, %ld, %ld] counts\n", desc, samples, to_s(steady_clock::now() - start), count[0], count[1], count[2]); } int diff --git a/staging_vespalib/src/tests/rusage/rusage_test.cpp b/staging_vespalib/src/tests/rusage/rusage_test.cpp index 942140086d6..0f2992e09e8 100644 --- a/staging_vespalib/src/tests/rusage/rusage_test.cpp +++ b/staging_vespalib/src/tests/rusage/rusage_test.cpp @@ -5,23 +5,7 @@ using namespace vespalib; -class Test : public TestApp -{ -public: - int Main() override; - void testRUsage(); -}; - -int -Test::Main() -{ - TEST_INIT("rusage_test"); - testRUsage(); - TEST_DONE(); -} - -void -Test::testRUsage() +TEST("testRUsage") { RUsage r1; EXPECT_EQUAL("", r1.toString()); @@ -30,12 +14,12 @@ Test::testRUsage() RUsage diff = r2-r1; EXPECT_EQUAL(diff.toString(), r2.toString()); { - RUsage then = RUsage::createSelf(steady_time(duration(7))); + RUsage then = RUsage::createSelf(steady_time(7ns)); RUsage now = RUsage::createSelf(); EXPECT_NOT_EQUAL(now.toString(), then.toString()); } { - RUsage then = RUsage::createChildren(steady_time(duration(1337583))); + RUsage then = RUsage::createChildren(steady_time(1337583ns)); RUsage now = RUsage::createChildren(); EXPECT_NOT_EQUAL(now.toString(), then.toString()); } @@ -70,4 +54,4 @@ Test::testRUsage() } } -TEST_APPHOOK(Test) +TEST_MAIN() { TEST_RUN_ALL(); } -- cgit v1.2.3