diff options
author | Evan Brown <ezb@google.com> | 2023-08-04 10:34:09 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-08-04 10:35:17 -0700 |
commit | 8f241e778c08cfb4213877b5022442a8d1921b58 (patch) | |
tree | f61de6bad1cbf5f6feb9ab96ea156bb44f8ea683 /absl/container/internal/hashtablez_sampler_test.cc | |
parent | 039d70f69b34b59d9696c655689316a94026fd0e (diff) | |
download | abseil-8f241e778c08cfb4213877b5022442a8d1921b58.tar.gz abseil-8f241e778c08cfb4213877b5022442a8d1921b58.tar.bz2 abseil-8f241e778c08cfb4213877b5022442a8d1921b58.zip |
Store infoz on the heap instead of inline and store it only when we are sampling the current allocation.
PiperOrigin-RevId: 553847957
Change-Id: Idd131d0362bf36bd22d9bd20df54bd9ae50f0e28
Diffstat (limited to 'absl/container/internal/hashtablez_sampler_test.cc')
-rw-r--r-- | absl/container/internal/hashtablez_sampler_test.cc | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/absl/container/internal/hashtablez_sampler_test.cc b/absl/container/internal/hashtablez_sampler_test.cc index 665d518f..8ebb08da 100644 --- a/absl/container/internal/hashtablez_sampler_test.cc +++ b/absl/container/internal/hashtablez_sampler_test.cc @@ -42,16 +42,11 @@ namespace container_internal { #if defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) class HashtablezInfoHandlePeer { public: - static bool IsSampled(const HashtablezInfoHandle& h) { - return h.info_ != nullptr; - } - static HashtablezInfo* GetInfo(HashtablezInfoHandle* h) { return h->info_; } }; #else class HashtablezInfoHandlePeer { public: - static bool IsSampled(const HashtablezInfoHandle&) { return false; } static HashtablezInfo* GetInfo(HashtablezInfoHandle*) { return nullptr; } }; #endif // defined(ABSL_INTERNAL_HASHTABLEZ_SAMPLE) @@ -267,7 +262,7 @@ TEST(HashtablezSamplerTest, Sample) { for (int i = 0; i < 1000000; ++i) { HashtablezInfoHandle h = Sample(test_element_size); ++total; - if (HashtablezInfoHandlePeer::IsSampled(h)) { + if (h.IsSampled()) { ++num_sampled; } sample_rate = static_cast<double>(num_sampled) / total; @@ -294,6 +289,7 @@ TEST(HashtablezSamplerTest, Handle) { }); EXPECT_TRUE(found); + h.Unregister(); h = HashtablezInfoHandle(); found = false; sampler.Iterate([&](const HashtablezInfo& h) { |