mirror of
https://github.com/gperftools/gperftools
synced 2025-01-05 05:59:34 +00:00
provide constexpr constructor for Sampler
Constexpr constructor lets us use Sampler in TLS variable in cleaner way.
This commit is contained in:
parent
1fb543cc70
commit
467502e70a
@ -105,6 +105,8 @@ class SamplerTest;
|
||||
|
||||
class PERFTOOLS_DLL_DECL Sampler {
|
||||
public:
|
||||
constexpr Sampler() {}
|
||||
|
||||
// Initialize this sampler.
|
||||
void Init(uint64_t seed);
|
||||
|
||||
@ -144,13 +146,13 @@ class PERFTOOLS_DLL_DECL Sampler {
|
||||
//
|
||||
// Always non-negative with only very brief exceptions (see
|
||||
// DecrementFast{,Finish}, so casting to size_t is ok.
|
||||
ssize_t bytes_until_sample_;
|
||||
uint64_t rnd_; // Cheap random number generator
|
||||
bool initialized_;
|
||||
|
||||
private:
|
||||
friend class SamplerTest;
|
||||
bool RecordAllocationSlow(size_t k);
|
||||
|
||||
ssize_t bytes_until_sample_{};
|
||||
uint64_t rnd_{}; // Cheap random number generator
|
||||
bool initialized_{};
|
||||
};
|
||||
|
||||
inline bool Sampler::RecordAllocation(size_t k) {
|
||||
|
@ -361,7 +361,7 @@ double StandardDeviationsErrorInSample(
|
||||
}
|
||||
|
||||
TEST(Sampler, LargeAndSmallAllocs_CombinedTest) {
|
||||
tcmalloc::Sampler sampler{0, 0, false};
|
||||
tcmalloc::Sampler sampler;
|
||||
sampler.Init(1);
|
||||
int counter_big = 0;
|
||||
int counter_small = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user