chromium/base/metrics/sample_vector.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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"

// This SampleVector makes use of the single-sample embedded in the base
// HistogramSamples class. If the count is non-zero then there is guaranteed
// (within the bounds of "eventual consistency") to be no allocated external
// storage. Once the full counts storage is allocated, the single-sample must
// be extracted and disabled.

namespace base {

Count;
Sample;

namespace {

// An iterator for sample vectors.
template <typename T>
class IteratorTemplate : public SampleCountIterator {};

SampleVectorIterator;

template <>
SampleVectorIterator::~IteratorTemplate() = default;

// Get() for an iterator of a SampleVector.
template <>
void SampleVectorIterator::Get(HistogramBase::Sample* min,
                               int64_t* max,
                               HistogramBase::Count* count) {}

ExtractingSampleVectorIterator;

template <>
ExtractingSampleVectorIterator::~IteratorTemplate() {}

// Get() for an extracting iterator of a SampleVector.
template <>
void ExtractingSampleVectorIterator::Get(HistogramBase::Sample* min,
                                         int64_t* max,
                                         HistogramBase::Count* count) {}

}  // namespace

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) {}

// Uses simple binary search or calculates the index directly if it's an "exact"
// linear histogram. This is very general, but there are better approaches if we
// knew that the buckets were linearly distributed.
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() {}

}  // namespace base