Cache: Specify item count explcitly in tests
This commit is contained in:
@ -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...
|
||||
}
|
||||
|
@ -77,11 +77,13 @@ public:
|
||||
*
|
||||
* @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. */
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
Reference in New Issue
Block a user