diff --git a/src/lib/uninitialised-storage.hpp b/src/lib/uninitialised-storage.hpp index 3f28f0d11..466582bba 100644 --- a/src/lib/uninitialised-storage.hpp +++ b/src/lib/uninitialised-storage.hpp @@ -137,7 +137,7 @@ namespace lib { { using _Arr = T[]; - T* buff_{nullptr}; + void* buff_{nullptr}; size_t size_{0}; public: @@ -146,9 +146,9 @@ namespace lib { { if (buff_) discard(); size_ = cnt; - buff_ = cnt? static_cast (std::aligned_alloc (std::alignment_of(), cnt * sizeof(T))) + buff_ = cnt? std::aligned_alloc (std::alignment_of(), cnt * sizeof(T)) : nullptr; - return buff_; + return front(); } void @@ -216,6 +216,13 @@ namespace lib { } + T * front() { return &array()[0]; } + T const* front() const { return &array()[0]; } + T * after() { return &array()[size_];} + T const* after() const { return &array()[size_];} + T * back () { return after() - 1; } + T const* back () const { return after() - 1; } + T & operator[] (size_t idx) { return array()[idx]; } T const& operator[] (size_t idx) const { return array()[idx]; } diff --git a/tests/vault/gear/test-chain-load-test.cpp b/tests/vault/gear/test-chain-load-test.cpp index a54fc5835..1192822e2 100644 --- a/tests/vault/gear/test-chain-load-test.cpp +++ b/tests/vault/gear/test-chain-load-test.cpp @@ -872,6 +872,7 @@ SHOW_EXPR(testLoad.getHash()) { ComputationalLoad cpuLoad; CHECK (cpuLoad.timeBase == 100us); + cpuLoad.useAllocation = true; double micros = cpuLoad.invoke(); SHOW_EXPR(micros) @@ -882,13 +883,13 @@ SHOW_EXPR(micros) micros = cpuLoad.invoke(); SHOW_EXPR(micros) - CHECK (micros < 123); + CHECK (micros < 133); CHECK (micros > 80); micros = cpuLoad.benchmark(); SHOW_EXPR(micros) - CHECK (micros < 105); - CHECK (micros > 95); + CHECK (micros < 110); + CHECK (micros > 90); } diff --git a/tests/vault/gear/test-chain-load.hpp b/tests/vault/gear/test-chain-load.hpp index ae7675b15..679786451 100644 --- a/tests/vault/gear/test-chain-load.hpp +++ b/tests/vault/gear/test-chain-load.hpp @@ -139,6 +139,7 @@ namespace test { using lib::meta::_FunRet; using lib::test::Transiently; + using std::make_pair; using std::forward; using std::string; using std::swap; @@ -1079,23 +1080,29 @@ namespace test { */ class ComputationalLoad { - lib::UninitialisedDynBlock memBlock_{}; + using Sink = volatile size_t; + + lib::UninitialisedDynBlock memBlock_{}; static double& - computationSpeed() ///< in iterations/µs + computationSpeed (bool mem) ///< in iterations/µs { - static double speed{LOAD_SPEED_BASELINE}; - return speed; + static double cpuSpeed{LOAD_SPEED_BASELINE}; + static double memSpeed{LOAD_SPEED_BASELINE}; + return mem? memSpeed : cpuSpeed; } public: microseconds timeBase = 100us; + size_t sizeBase = 1000; bool useAllocation = false; double invoke (uint scaleStep =1) { - return benchmarkTime ([this,scaleStep]{ causeComputationLoad(scaleStep); }); + if (scaleStep == 0) return 0; + return useAllocation? benchmarkTime ([this,scaleStep]{ causeMemProcessLoad (scaleStep); }) + : benchmarkTime ([this,scaleStep]{ causeComputationLoad(scaleStep); }); } double @@ -1109,13 +1116,13 @@ namespace test { void calibrate() { -cout<<">CAL: speed="<CAL: speed="< - + - - + + + @@ -99579,6 +99580,23 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + +

+ legt die Eichungs-Konstanten statisch ab +

+ + +
+ + + + +
@@ -99600,6 +99618,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + @@ -99610,7 +99631,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + @@ -99626,7 +99647,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200

- Stelle schon mal fest: der Einzel-Lauf streut ganz deutlich. Und Cache-Effekte könnten auch noch ein gewisses Problem darstellen (wenngleich auch der vorangegangene Test grundsätzlich den Code schon vorgewärmt  hat. Also setze mal  ±20% für den Einzeltest an, aber nur ±5% für den Benchmark + Stelle schon mal fest: der Einzel-Lauf streut ganz deutlich. Und Cache-Effekte könnten auch noch ein gewisses Problem darstellen (wenngleich auch der vorangegangene Test grundsätzlich den Code schon vorgewärmt  hat. Also setze mal  ±30% für den Einzeltest an, aber nur ±10% für den Benchmark