From 9998f60493054e6933559c9aa7c88ce2ae8b5f99 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 16 Dec 2016 14:41:26 +0200 Subject: [PATCH] Cache: Specify item count explcitly in tests --- .../filter/cache/test/testerstorage.cc | 11 ++-------- .../filter/cache/test/testerstorage.hh | 20 ++++++------------- .../filter/cache/test/testlrustorage.cc | 5 +++-- .../filter/cache/test/testrawstorage.cc | 5 +++-- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/server/modules/filter/cache/test/testerstorage.cc b/server/modules/filter/cache/test/testerstorage.cc index 9d5a820e9..39afd3688 100644 --- a/server/modules/filter/cache/test/testerstorage.cc +++ b/server/modules/filter/cache/test/testerstorage.cc @@ -143,15 +143,13 @@ TesterStorage::TesterStorage(std::ostream* pOut, StorageFactory* pFactory) { } -int TesterStorage::run(size_t n_threads, size_t n_seconds, std::istream& in) +int TesterStorage::run(size_t n_threads, size_t n_seconds, size_t n_max_items, std::istream& in) { int rv = EXIT_FAILURE; - size_t n_items = get_n_items(n_threads, n_seconds); - CacheItems cache_items; - if (get_cache_items(in, n_items, m_factory, &cache_items)) + if (get_cache_items(in, n_max_items, m_factory, &cache_items)) { rv = execute(n_threads, n_seconds, cache_items); } @@ -255,8 +253,3 @@ TesterStorage::storage_action_t TesterStorage::get_random_action() return action; } - -size_t TesterStorage::get_n_items(size_t n_threads, size_t n_seconds) -{ - return n_threads * n_seconds * 10; // From the sleeve... -} diff --git a/server/modules/filter/cache/test/testerstorage.hh b/server/modules/filter/cache/test/testerstorage.hh index 2abc6a6f4..48b2f26d0 100644 --- a/server/modules/filter/cache/test/testerstorage.hh +++ b/server/modules/filter/cache/test/testerstorage.hh @@ -75,13 +75,15 @@ public: * * Will call back into the virtual @c execute function below. * - * @param n_threads How many threads to use. - * @param n_seconds For how many seconds to run the test. - * @param in Stream, assumed to refer to a file containing statements. + * @param n_threads How many threads to use. + * @param n_seconds For how many seconds to run the test. + * @param n_max_items How many items to read from the stream at most; 0 means + * no limit. + * @param in Stream, assumed to refer to a file containing statements. * * @return EXIT_SUCCESS or EXIT_FAILURE. */ - virtual int run(size_t n_threads, size_t n_seconds, std::istream& in); + virtual int run(size_t n_threads, size_t n_seconds, size_t n_max_items, std::istream& in); /** * Creates cache items with the size varying between the specified minimum @@ -162,16 +164,6 @@ protected: */ TesterStorage(std::ostream* pOut, StorageFactory* pFactory); - /** - * Return the desired number of cache items to be used in the tests. - * - * @param n_threads How many threads are used. - * @param n_seconds For how many seconds the tests will be run. - * - * @return The desired number of items to use. - */ - virtual size_t get_n_items(size_t n_threads, size_t n_seconds); - protected: StorageFactory& m_factory; /*< The storage factory that is used. */ diff --git a/server/modules/filter/cache/test/testlrustorage.cc b/server/modules/filter/cache/test/testlrustorage.cc index b54160ddc..600cf6697 100644 --- a/server/modules/filter/cache/test/testlrustorage.cc +++ b/server/modules/filter/cache/test/testlrustorage.cc @@ -65,10 +65,11 @@ int main(int argc, char* argv[]) TesterLRUStorage tester(&cout, pFactory); size_t n_threads = get_processor_count() + 1; + size_t n_max_items = n_threads * n_seconds * 10; if (argc == 3) { - rv = tester.run(n_threads, n_seconds, cin); + rv = tester.run(n_threads, n_seconds, n_max_items, cin); } else { @@ -76,7 +77,7 @@ int main(int argc, char* argv[]) if (in) { - rv = tester.run(n_threads, n_seconds, in); + rv = tester.run(n_threads, n_seconds, n_max_items, in); } else { diff --git a/server/modules/filter/cache/test/testrawstorage.cc b/server/modules/filter/cache/test/testrawstorage.cc index c823d610d..675a8674f 100644 --- a/server/modules/filter/cache/test/testrawstorage.cc +++ b/server/modules/filter/cache/test/testrawstorage.cc @@ -65,10 +65,11 @@ int main(int argc, char* argv[]) TesterRawStorage tester(&cout, pFactory); size_t n_threads = get_processor_count() + 1; + size_t n_max_items = n_threads * n_seconds * 10; if (argc == 3) { - rv = tester.run(n_threads, n_seconds, cin); + rv = tester.run(n_threads, n_seconds, n_max_items, cin); } else { @@ -76,7 +77,7 @@ int main(int argc, char* argv[]) if (in) { - rv = tester.run(n_threads, n_seconds, in); + rv = tester.run(n_threads, n_seconds, n_max_items, in); } else {