diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2018-12-21 12:09:51 -0500 |
---|---|---|
committer | Henrik Edin <henrik.edin@mongodb.com> | 2018-12-21 14:10:29 -0500 |
commit | d0912b94ee141d46c14c00ba30d28037d5464af0 (patch) | |
tree | 09458189f1ee638f6c5ebbaed3e8cde27c1e7108 /src/mongo/util | |
parent | 9e3ff3f74542c8e621934e0f44b15072ee8945be (diff) | |
download | mongo-d0912b94ee141d46c14c00ba30d28037d5464af0.tar.gz |
SERVER-38739 Reduce iterations in lru_cache_test StressTest if iterator debugging is on. The destructor becomes O(n^2)
Diffstat (limited to 'src/mongo/util')
-rw-r--r-- | src/mongo/util/lru_cache_test.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/util/lru_cache_test.cpp b/src/mongo/util/lru_cache_test.cpp index 70cb618d1c2..af3f5c9e208 100644 --- a/src/mongo/util/lru_cache_test.cpp +++ b/src/mongo/util/lru_cache_test.cpp @@ -215,7 +215,16 @@ TEST(LRUCacheTest, SizeZeroCache) { // Test a very large cache size TEST(LRUCacheTest, StressTest) { +// If iterator debugging is on the LRU Cache destructor may be O(n^2). Reduce the max iteration size +// to handle this. +#if _MSC_VER && _ITERATOR_DEBUG_LEVEL >= 2 + const int maxSize = 10000; + std::array<int, 3> sample{1, 34, 400}; +#else const int maxSize = 1000000; + std::array<int, 5> sample{1, 34, 400, 12345, 999999}; +#endif + LRUCache<int, int> cache(maxSize); // Fill up the cache @@ -227,7 +236,6 @@ TEST(LRUCacheTest, StressTest) { assertEquals(cache.size(), size_t(maxSize)); // Perform some basic functions on the cache - std::array<int, 5> sample{1, 34, 400, 12345, 999999}; for (auto s : sample) { auto found = cache.find(s); assertEquals(found->second, s); |