#include "base/metrics/sample_vector.h"
#include <ostream>
#include <string_view>
#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/containers/heap_array.h"
#include "base/debug/crash_logging.h"
#include "base/debug/leak_annotations.h"
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_span.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
namespace base {
Count;
Sample;
namespace {
template <typename T>
class IteratorTemplate : public SampleCountIterator { … };
SampleVectorIterator;
template <>
SampleVectorIterator::~IteratorTemplate() = default;
template <>
void SampleVectorIterator::Get(HistogramBase::Sample* min,
int64_t* max,
HistogramBase::Count* count) { … }
ExtractingSampleVectorIterator;
template <>
ExtractingSampleVectorIterator::~IteratorTemplate() { … }
template <>
void ExtractingSampleVectorIterator::Get(HistogramBase::Sample* min,
int64_t* max,
HistogramBase::Count* count) { … }
}
SampleVectorBase::SampleVectorBase(uint64_t id,
Metadata* meta,
const BucketRanges* bucket_ranges)
: … { … }
SampleVectorBase::SampleVectorBase(uint64_t id,
std::unique_ptr<Metadata> meta,
const BucketRanges* bucket_ranges)
: … { … }
SampleVectorBase::~SampleVectorBase() = default;
void SampleVectorBase::Accumulate(Sample value, Count count) { … }
Count SampleVectorBase::GetCount(Sample value) const { … }
Count SampleVectorBase::TotalCount() const { … }
Count SampleVectorBase::GetCountAtIndex(size_t bucket_index) const { … }
std::unique_ptr<SampleCountIterator> SampleVectorBase::Iterator() const { … }
std::unique_ptr<SampleCountIterator> SampleVectorBase::ExtractingIterator() { … }
bool SampleVectorBase::AddSubtractImpl(SampleCountIterator* iter,
HistogramSamples::Operator op) { … }
size_t SampleVectorBase::GetBucketIndex(Sample value) const { … }
void SampleVectorBase::MoveSingleSampleToCounts() { … }
void SampleVectorBase::MountCountsStorageAndMoveSingleSample() { … }
SampleVector::SampleVector(const BucketRanges* bucket_ranges)
: … { … }
SampleVector::SampleVector(uint64_t id, const BucketRanges* bucket_ranges)
: … { … }
SampleVector::~SampleVector() = default;
bool SampleVector::IsDefinitelyEmpty() const { … }
bool SampleVector::MountExistingCountsStorage() const { … }
std::string SampleVector::GetAsciiHeader(std::string_view histogram_name,
int32_t flags) const { … }
std::string SampleVector::GetAsciiBody() const { … }
double SampleVector::GetPeakBucketSize() const { … }
void SampleVector::WriteAsciiBucketContext(int64_t past,
Count current,
int64_t remaining,
uint32_t current_bucket_index,
std::string* output) const { … }
span<HistogramBase::AtomicCount>
SampleVector::CreateCountsStorageWhileLocked() { … }
PersistentSampleVector::PersistentSampleVector(
uint64_t id,
const BucketRanges* bucket_ranges,
Metadata* meta,
const DelayedPersistentAllocation& counts)
: … { … }
PersistentSampleVector::~PersistentSampleVector() = default;
bool PersistentSampleVector::IsDefinitelyEmpty() const { … }
bool PersistentSampleVector::MountExistingCountsStorage() const { … }
span<HistogramBase::AtomicCount>
PersistentSampleVector::CreateCountsStorageWhileLocked() { … }
}