Connect SparseHistogram with the rest of stats system
With this CL, SparseHistogram is usable with SparseHistogram::FactoryGet. Next step is to implement a Histogram like macro and implement WriteHTMLGraph and WriteAscii to have a nice output. BUG=139612 Review URL: https://chromiumcodereview.appspot.com/12207058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185451 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
base/metrics
histogram.cchistogram.hhistogram_base.cchistogram_base.hhistogram_base_unittest.cchistogram_flattener.hhistogram_snapshot_manager.cchistogram_snapshot_manager.hhistogram_unittest.ccsparse_histogram.ccstatistics_recorder.ccstatistics_recorder.h
chrome
browser
common
test
content
browser
common
renderer
dbus
net
disk_cache
socket_stream
url_request
@@ -84,29 +84,6 @@ typedef HistogramBase::Sample Sample;
|
|||||||
// static
|
// static
|
||||||
const size_t Histogram::kBucketCount_MAX = 16384u;
|
const size_t Histogram::kBucketCount_MAX = 16384u;
|
||||||
|
|
||||||
// TODO(rtenneti): delete this code after debugging.
|
|
||||||
void CheckCorruption(const Histogram& histogram, bool new_histogram) {
|
|
||||||
const std::string& histogram_name = histogram.histogram_name();
|
|
||||||
char histogram_name_buf[128];
|
|
||||||
base::strlcpy(histogram_name_buf,
|
|
||||||
histogram_name.c_str(),
|
|
||||||
arraysize(histogram_name_buf));
|
|
||||||
base::debug::Alias(histogram_name_buf);
|
|
||||||
|
|
||||||
bool debug_new_histogram[1];
|
|
||||||
debug_new_histogram[0] = new_histogram;
|
|
||||||
base::debug::Alias(debug_new_histogram);
|
|
||||||
|
|
||||||
Sample previous_range = -1; // Bottom range is always 0.
|
|
||||||
for (size_t index = 0; index < histogram.bucket_count(); ++index) {
|
|
||||||
int new_range = histogram.ranges(index);
|
|
||||||
CHECK_LT(previous_range, new_range);
|
|
||||||
previous_range = new_range;
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK(histogram.bucket_ranges()->HasValidChecksum());
|
|
||||||
}
|
|
||||||
|
|
||||||
HistogramBase* Histogram::FactoryGet(const string& name,
|
HistogramBase* Histogram::FactoryGet(const string& name,
|
||||||
Sample minimum,
|
Sample minimum,
|
||||||
Sample maximum,
|
Sample maximum,
|
||||||
@@ -116,7 +93,7 @@ HistogramBase* Histogram::FactoryGet(const string& name,
|
|||||||
InspectConstructionArguments(name, &minimum, &maximum, &bucket_count);
|
InspectConstructionArguments(name, &minimum, &maximum, &bucket_count);
|
||||||
DCHECK(valid_arguments);
|
DCHECK(valid_arguments);
|
||||||
|
|
||||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||||
if (!histogram) {
|
if (!histogram) {
|
||||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||||
BucketRanges* ranges = new BucketRanges(bucket_count + 1);
|
BucketRanges* ranges = new BucketRanges(bucket_count + 1);
|
||||||
@@ -126,16 +103,13 @@ HistogramBase* Histogram::FactoryGet(const string& name,
|
|||||||
|
|
||||||
Histogram* tentative_histogram =
|
Histogram* tentative_histogram =
|
||||||
new Histogram(name, minimum, maximum, bucket_count, registered_ranges);
|
new Histogram(name, minimum, maximum, bucket_count, registered_ranges);
|
||||||
CheckCorruption(*tentative_histogram, true);
|
|
||||||
|
|
||||||
tentative_histogram->SetFlags(flags);
|
tentative_histogram->SetFlags(flags);
|
||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||||
}
|
}
|
||||||
// TODO(rtenneti): delete this code after debugging.
|
|
||||||
CheckCorruption(*histogram, false);
|
|
||||||
|
|
||||||
CHECK_EQ(HISTOGRAM, histogram->GetHistogramType());
|
DCHECK_EQ(HISTOGRAM, histogram->GetHistogramType());
|
||||||
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
|
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
|
||||||
return histogram;
|
return histogram;
|
||||||
}
|
}
|
||||||
@@ -200,8 +174,7 @@ void Histogram::InitializeBucketRanges(Sample minimum,
|
|||||||
// static
|
// static
|
||||||
const int Histogram::kCommonRaceBasedCountMismatch = 5;
|
const int Histogram::kCommonRaceBasedCountMismatch = 5;
|
||||||
|
|
||||||
Histogram::Inconsistencies Histogram::FindCorruption(
|
int Histogram::FindCorruption(const HistogramSamples& samples) const {
|
||||||
const HistogramSamples& samples) const {
|
|
||||||
int inconsistencies = NO_INCONSISTENCIES;
|
int inconsistencies = NO_INCONSISTENCIES;
|
||||||
Sample previous_range = -1; // Bottom range is always 0.
|
Sample previous_range = -1; // Bottom range is always 0.
|
||||||
for (size_t index = 0; index < bucket_count(); ++index) {
|
for (size_t index = 0; index < bucket_count(); ++index) {
|
||||||
@@ -230,7 +203,7 @@ Histogram::Inconsistencies Histogram::FindCorruption(
|
|||||||
inconsistencies |= COUNT_LOW_ERROR;
|
inconsistencies |= COUNT_LOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return static_cast<Inconsistencies>(inconsistencies);
|
return inconsistencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sample Histogram::ranges(size_t i) const {
|
Sample Histogram::ranges(size_t i) const {
|
||||||
@@ -599,7 +572,7 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
|
|||||||
name, &minimum, &maximum, &bucket_count);
|
name, &minimum, &maximum, &bucket_count);
|
||||||
DCHECK(valid_arguments);
|
DCHECK(valid_arguments);
|
||||||
|
|
||||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||||
if (!histogram) {
|
if (!histogram) {
|
||||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||||
BucketRanges* ranges = new BucketRanges(bucket_count + 1);
|
BucketRanges* ranges = new BucketRanges(bucket_count + 1);
|
||||||
@@ -610,7 +583,6 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
|
|||||||
LinearHistogram* tentative_histogram =
|
LinearHistogram* tentative_histogram =
|
||||||
new LinearHistogram(name, minimum, maximum, bucket_count,
|
new LinearHistogram(name, minimum, maximum, bucket_count,
|
||||||
registered_ranges);
|
registered_ranges);
|
||||||
CheckCorruption(*tentative_histogram, true);
|
|
||||||
|
|
||||||
// Set range descriptions.
|
// Set range descriptions.
|
||||||
if (descriptions) {
|
if (descriptions) {
|
||||||
@@ -624,10 +596,8 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
|
|||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||||
}
|
}
|
||||||
// TODO(rtenneti): delete this code after debugging.
|
|
||||||
CheckCorruption(*histogram, false);
|
|
||||||
|
|
||||||
CHECK_EQ(LINEAR_HISTOGRAM, histogram->GetHistogramType());
|
DCHECK_EQ(LINEAR_HISTOGRAM, histogram->GetHistogramType());
|
||||||
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
|
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
|
||||||
return histogram;
|
return histogram;
|
||||||
}
|
}
|
||||||
@@ -710,7 +680,7 @@ HistogramBase* LinearHistogram::DeserializeInfoImpl(PickleIterator* iter) {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
HistogramBase* BooleanHistogram::FactoryGet(const string& name, int32 flags) {
|
HistogramBase* BooleanHistogram::FactoryGet(const string& name, int32 flags) {
|
||||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||||
if (!histogram) {
|
if (!histogram) {
|
||||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||||
BucketRanges* ranges = new BucketRanges(4);
|
BucketRanges* ranges = new BucketRanges(4);
|
||||||
@@ -720,16 +690,13 @@ HistogramBase* BooleanHistogram::FactoryGet(const string& name, int32 flags) {
|
|||||||
|
|
||||||
BooleanHistogram* tentative_histogram =
|
BooleanHistogram* tentative_histogram =
|
||||||
new BooleanHistogram(name, registered_ranges);
|
new BooleanHistogram(name, registered_ranges);
|
||||||
CheckCorruption(*tentative_histogram, true);
|
|
||||||
|
|
||||||
tentative_histogram->SetFlags(flags);
|
tentative_histogram->SetFlags(flags);
|
||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||||
}
|
}
|
||||||
// TODO(rtenneti): delete this code after debugging.
|
|
||||||
CheckCorruption(*histogram, false);
|
|
||||||
|
|
||||||
CHECK_EQ(BOOLEAN_HISTOGRAM, histogram->GetHistogramType());
|
DCHECK_EQ(BOOLEAN_HISTOGRAM, histogram->GetHistogramType());
|
||||||
return histogram;
|
return histogram;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -772,7 +739,7 @@ HistogramBase* CustomHistogram::FactoryGet(const string& name,
|
|||||||
int32 flags) {
|
int32 flags) {
|
||||||
CHECK(ValidateCustomRanges(custom_ranges));
|
CHECK(ValidateCustomRanges(custom_ranges));
|
||||||
|
|
||||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||||
if (!histogram) {
|
if (!histogram) {
|
||||||
BucketRanges* ranges = CreateBucketRangesFromCustomRanges(custom_ranges);
|
BucketRanges* ranges = CreateBucketRangesFromCustomRanges(custom_ranges);
|
||||||
const BucketRanges* registered_ranges =
|
const BucketRanges* registered_ranges =
|
||||||
@@ -781,17 +748,14 @@ HistogramBase* CustomHistogram::FactoryGet(const string& name,
|
|||||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||||
CustomHistogram* tentative_histogram =
|
CustomHistogram* tentative_histogram =
|
||||||
new CustomHistogram(name, registered_ranges);
|
new CustomHistogram(name, registered_ranges);
|
||||||
CheckCorruption(*tentative_histogram, true);
|
|
||||||
|
|
||||||
tentative_histogram->SetFlags(flags);
|
tentative_histogram->SetFlags(flags);
|
||||||
|
|
||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||||
}
|
}
|
||||||
// TODO(rtenneti): delete this code after debugging.
|
|
||||||
CheckCorruption(*histogram, false);
|
|
||||||
|
|
||||||
CHECK_EQ(histogram->GetHistogramType(), CUSTOM_HISTOGRAM);
|
DCHECK_EQ(histogram->GetHistogramType(), CUSTOM_HISTOGRAM);
|
||||||
return histogram;
|
return histogram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -369,16 +369,6 @@ class BASE_EXPORT Histogram : public HistogramBase {
|
|||||||
|
|
||||||
typedef std::vector<Count> Counts;
|
typedef std::vector<Count> Counts;
|
||||||
|
|
||||||
enum Inconsistencies {
|
|
||||||
NO_INCONSISTENCIES = 0x0,
|
|
||||||
RANGE_CHECKSUM_ERROR = 0x1,
|
|
||||||
BUCKET_ORDER_ERROR = 0x2,
|
|
||||||
COUNT_HIGH_ERROR = 0x4,
|
|
||||||
COUNT_LOW_ERROR = 0x8,
|
|
||||||
|
|
||||||
NEVER_EXCEEDED_VALUE = 0x10
|
|
||||||
};
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// For a valid histogram, input should follow these restrictions:
|
// For a valid histogram, input should follow these restrictions:
|
||||||
// minimum > 0 (if a minimum below 1 is specified, it will implicitly be
|
// minimum > 0 (if a minimum below 1 is specified, it will implicitly be
|
||||||
@@ -423,7 +413,7 @@ class BASE_EXPORT Histogram : public HistogramBase {
|
|||||||
// produce a false-alarm if a race occurred in the reading of the data during
|
// produce a false-alarm if a race occurred in the reading of the data during
|
||||||
// a SnapShot process, but should otherwise be false at all times (unless we
|
// a SnapShot process, but should otherwise be false at all times (unless we
|
||||||
// have memory over-writes, or DRAM failures).
|
// have memory over-writes, or DRAM failures).
|
||||||
virtual Inconsistencies FindCorruption(const HistogramSamples& samples) const;
|
virtual int FindCorruption(const HistogramSamples& samples) const OVERRIDE;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Accessors for factory constuction, serialization and testing.
|
// Accessors for factory constuction, serialization and testing.
|
||||||
|
@@ -100,6 +100,11 @@ bool HistogramBase::SerializeInfo(Pickle* pickle) const {
|
|||||||
return SerializeInfoImpl(pickle);
|
return SerializeInfoImpl(pickle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int HistogramBase::FindCorruption(const HistogramSamples& samples) const {
|
||||||
|
// Not supported by default.
|
||||||
|
return NO_INCONSISTENCIES;
|
||||||
|
}
|
||||||
|
|
||||||
void HistogramBase::WriteJSON(std::string* output) const {
|
void HistogramBase::WriteJSON(std::string* output) const {
|
||||||
Count count;
|
Count count;
|
||||||
scoped_ptr<ListValue> buckets(new ListValue());
|
scoped_ptr<ListValue> buckets(new ListValue());
|
||||||
|
@@ -70,6 +70,17 @@ class BASE_EXPORT HistogramBase {
|
|||||||
kHexRangePrintingFlag = 0x8000,
|
kHexRangePrintingFlag = 0x8000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Histogram data inconsistency types.
|
||||||
|
enum Inconsistency {
|
||||||
|
NO_INCONSISTENCIES = 0x0,
|
||||||
|
RANGE_CHECKSUM_ERROR = 0x1,
|
||||||
|
BUCKET_ORDER_ERROR = 0x2,
|
||||||
|
COUNT_HIGH_ERROR = 0x4,
|
||||||
|
COUNT_LOW_ERROR = 0x8,
|
||||||
|
|
||||||
|
NEVER_EXCEEDED_VALUE = 0x10
|
||||||
|
};
|
||||||
|
|
||||||
explicit HistogramBase(const std::string& name);
|
explicit HistogramBase(const std::string& name);
|
||||||
virtual ~HistogramBase();
|
virtual ~HistogramBase();
|
||||||
|
|
||||||
@@ -103,6 +114,10 @@ class BASE_EXPORT HistogramBase {
|
|||||||
// does not serialize the samples.
|
// does not serialize the samples.
|
||||||
bool SerializeInfo(Pickle* pickle) const;
|
bool SerializeInfo(Pickle* pickle) const;
|
||||||
|
|
||||||
|
// Try to find out data corruption from histogram and the samples.
|
||||||
|
// The returned value is a combination of Inconsistency enum.
|
||||||
|
virtual int FindCorruption(const HistogramSamples& samples) const;
|
||||||
|
|
||||||
// Snapshot the current complete set of sample data.
|
// Snapshot the current complete set of sample data.
|
||||||
// Override with atomic/locked snapshot if needed.
|
// Override with atomic/locked snapshot if needed.
|
||||||
virtual scoped_ptr<HistogramSamples> SnapshotSamples() const = 0;
|
virtual scoped_ptr<HistogramSamples> SnapshotSamples() const = 0;
|
||||||
|
@@ -167,6 +167,25 @@ TEST_F(HistogramBaseTest, DeserializeCustomHistogram) {
|
|||||||
EXPECT_EQ(0, deserialized->flags());
|
EXPECT_EQ(0, deserialized->flags());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(kaiwang): Add SparseHistogram test.
|
TEST_F(HistogramBaseTest, DeserializeSparseHistogram) {
|
||||||
|
HistogramBase* histogram = SparseHistogram::FactoryGet(
|
||||||
|
"TestHistogram", HistogramBase::kIPCSerializationSourceFlag);
|
||||||
|
|
||||||
|
Pickle pickle;
|
||||||
|
ASSERT_TRUE(histogram->SerializeInfo(&pickle));
|
||||||
|
|
||||||
|
PickleIterator iter(pickle);
|
||||||
|
HistogramBase* deserialized = DeserializeHistogramInfo(&iter);
|
||||||
|
EXPECT_EQ(histogram, deserialized);
|
||||||
|
|
||||||
|
ResetStatisticsRecorder();
|
||||||
|
|
||||||
|
PickleIterator iter2(pickle);
|
||||||
|
deserialized = DeserializeHistogramInfo(&iter2);
|
||||||
|
EXPECT_TRUE(deserialized);
|
||||||
|
EXPECT_NE(histogram, deserialized);
|
||||||
|
EXPECT_EQ("TestHistogram", deserialized->histogram_name());
|
||||||
|
EXPECT_EQ(0, deserialized->flags());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
@@ -24,14 +24,14 @@ class BASE_EXPORT HistogramFlattener {
|
|||||||
virtual void RecordDelta(const HistogramBase& histogram,
|
virtual void RecordDelta(const HistogramBase& histogram,
|
||||||
const HistogramSamples& snapshot) = 0;
|
const HistogramSamples& snapshot) = 0;
|
||||||
|
|
||||||
// Will be called each time a type of Inconsistenies is seen on a histogram,
|
// Will be called each time a type of Inconsistency is seen on a histogram,
|
||||||
// during inspections done internally in HistogramSnapshotManager class.
|
// during inspections done internally in HistogramSnapshotManager class.
|
||||||
virtual void InconsistencyDetected(Histogram::Inconsistencies problem) = 0;
|
virtual void InconsistencyDetected(HistogramBase::Inconsistency problem) = 0;
|
||||||
|
|
||||||
// Will be called when a type of Inconsistenies is seen for the first time
|
// Will be called when a type of Inconsistency is seen for the first time on
|
||||||
// on a histogram.
|
// a histogram.
|
||||||
virtual void UniqueInconsistencyDetected(
|
virtual void UniqueInconsistencyDetected(
|
||||||
Histogram::Inconsistencies problem) = 0;
|
HistogramBase::Inconsistency problem) = 0;
|
||||||
|
|
||||||
// Will be called when the total logged sample count of a histogram
|
// Will be called when the total logged sample count of a histogram
|
||||||
// differs from the sum of logged sample count in all the buckets. The
|
// differs from the sum of logged sample count in all the buckets. The
|
||||||
|
@@ -25,7 +25,7 @@ HistogramSnapshotManager::~HistogramSnapshotManager() {
|
|||||||
STLDeleteValues(&logged_samples_);
|
STLDeleteValues(&logged_samples_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistogramSnapshotManager::PrepareDeltas(Histogram::Flags flag_to_set,
|
void HistogramSnapshotManager::PrepareDeltas(HistogramBase::Flags flag_to_set,
|
||||||
bool record_only_uma) {
|
bool record_only_uma) {
|
||||||
StatisticsRecorder::Histograms histograms;
|
StatisticsRecorder::Histograms histograms;
|
||||||
StatisticsRecorder::GetHistograms(&histograms);
|
StatisticsRecorder::GetHistograms(&histograms);
|
||||||
@@ -40,7 +40,7 @@ void HistogramSnapshotManager::PrepareDeltas(Histogram::Flags flag_to_set,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
|
void HistogramSnapshotManager::PrepareDelta(const HistogramBase& histogram) {
|
||||||
DCHECK(histogram_flattener_);
|
DCHECK(histogram_flattener_);
|
||||||
|
|
||||||
// Get up-to-date snapshot of sample stats.
|
// Get up-to-date snapshot of sample stats.
|
||||||
@@ -52,13 +52,13 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
|
|||||||
// Crash if we detect that our histograms have been overwritten. This may be
|
// Crash if we detect that our histograms have been overwritten. This may be
|
||||||
// a fair distance from the memory smasher, but we hope to correlate these
|
// a fair distance from the memory smasher, but we hope to correlate these
|
||||||
// crashes with other events, such as plugins, or usage patterns, etc.
|
// crashes with other events, such as plugins, or usage patterns, etc.
|
||||||
if (Histogram::BUCKET_ORDER_ERROR & corruption) {
|
if (HistogramBase::BUCKET_ORDER_ERROR & corruption) {
|
||||||
// The checksum should have caught this, so crash separately if it didn't.
|
// The checksum should have caught this, so crash separately if it didn't.
|
||||||
CHECK_NE(0, Histogram::RANGE_CHECKSUM_ERROR & corruption);
|
CHECK_NE(0, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
|
||||||
CHECK(false); // Crash for the bucket order corruption.
|
CHECK(false); // Crash for the bucket order corruption.
|
||||||
}
|
}
|
||||||
// Checksum corruption might not have caused order corruption.
|
// Checksum corruption might not have caused order corruption.
|
||||||
CHECK_EQ(0, Histogram::RANGE_CHECKSUM_ERROR & corruption);
|
CHECK_EQ(0, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
|
||||||
|
|
||||||
// Note, at this point corruption can only be COUNT_HIGH_ERROR or
|
// Note, at this point corruption can only be COUNT_HIGH_ERROR or
|
||||||
// COUNT_LOW_ERROR and they never arise together, so we don't need to extract
|
// COUNT_LOW_ERROR and they never arise together, so we don't need to extract
|
||||||
@@ -67,14 +67,14 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
|
|||||||
DLOG(ERROR) << "Histogram: " << histogram_name
|
DLOG(ERROR) << "Histogram: " << histogram_name
|
||||||
<< " has data corruption: " << corruption;
|
<< " has data corruption: " << corruption;
|
||||||
histogram_flattener_->InconsistencyDetected(
|
histogram_flattener_->InconsistencyDetected(
|
||||||
static_cast<Histogram::Inconsistencies>(corruption));
|
static_cast<HistogramBase::Inconsistency>(corruption));
|
||||||
// Don't record corrupt data to metrics services.
|
// Don't record corrupt data to metrics services.
|
||||||
int old_corruption = inconsistencies_[histogram_name];
|
int old_corruption = inconsistencies_[histogram_name];
|
||||||
if (old_corruption == (corruption | old_corruption))
|
if (old_corruption == (corruption | old_corruption))
|
||||||
return; // We've already seen this corruption for this histogram.
|
return; // We've already seen this corruption for this histogram.
|
||||||
inconsistencies_[histogram_name] |= corruption;
|
inconsistencies_[histogram_name] |= corruption;
|
||||||
histogram_flattener_->UniqueInconsistencyDetected(
|
histogram_flattener_->UniqueInconsistencyDetected(
|
||||||
static_cast<Histogram::Inconsistencies>(corruption));
|
static_cast<HistogramBase::Inconsistency>(corruption));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/metrics/histogram.h"
|
#include "base/metrics/histogram_base.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
@@ -31,11 +31,11 @@ class BASE_EXPORT HistogramSnapshotManager {
|
|||||||
// Snapshot all histograms, and ask |histogram_flattener_| to record the
|
// Snapshot all histograms, and ask |histogram_flattener_| to record the
|
||||||
// delta. The arguments allow selecting only a subset of histograms for
|
// delta. The arguments allow selecting only a subset of histograms for
|
||||||
// recording, or to set a flag in each recorded histogram.
|
// recording, or to set a flag in each recorded histogram.
|
||||||
void PrepareDeltas(Histogram::Flags flags_to_set, bool record_only_uma);
|
void PrepareDeltas(HistogramBase::Flags flags_to_set, bool record_only_uma);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Snapshot this histogram, and record the delta.
|
// Snapshot this histogram, and record the delta.
|
||||||
void PrepareDelta(const Histogram& histogram);
|
void PrepareDelta(const HistogramBase& histogram);
|
||||||
|
|
||||||
// Try to detect and fix count inconsistency of logged samples.
|
// Try to detect and fix count inconsistency of logged samples.
|
||||||
void InspectLoggedSamplesInconsistency(
|
void InspectLoggedSamplesInconsistency(
|
||||||
|
@@ -315,21 +315,21 @@ TEST_F(HistogramTest, CorruptSampleCounts) {
|
|||||||
histogram->Add(40);
|
histogram->Add(40);
|
||||||
|
|
||||||
scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
|
scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
|
||||||
EXPECT_EQ(Histogram::NO_INCONSISTENCIES,
|
EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
|
||||||
histogram->FindCorruption(*snapshot));
|
histogram->FindCorruption(*snapshot));
|
||||||
EXPECT_EQ(2, snapshot->redundant_count());
|
EXPECT_EQ(2, snapshot->redundant_count());
|
||||||
EXPECT_EQ(2, snapshot->TotalCount());
|
EXPECT_EQ(2, snapshot->TotalCount());
|
||||||
|
|
||||||
snapshot->counts_[3] += 100; // Sample count won't match redundant count.
|
snapshot->counts_[3] += 100; // Sample count won't match redundant count.
|
||||||
EXPECT_EQ(Histogram::COUNT_LOW_ERROR,
|
EXPECT_EQ(HistogramBase::COUNT_LOW_ERROR,
|
||||||
histogram->FindCorruption(*snapshot));
|
histogram->FindCorruption(*snapshot));
|
||||||
snapshot->counts_[2] -= 200;
|
snapshot->counts_[2] -= 200;
|
||||||
EXPECT_EQ(Histogram::COUNT_HIGH_ERROR,
|
EXPECT_EQ(HistogramBase::COUNT_HIGH_ERROR,
|
||||||
histogram->FindCorruption(*snapshot));
|
histogram->FindCorruption(*snapshot));
|
||||||
|
|
||||||
// But we can't spot a corruption if it is compensated for.
|
// But we can't spot a corruption if it is compensated for.
|
||||||
snapshot->counts_[1] += 100;
|
snapshot->counts_[1] += 100;
|
||||||
EXPECT_EQ(Histogram::NO_INCONSISTENCIES,
|
EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
|
||||||
histogram->FindCorruption(*snapshot));
|
histogram->FindCorruption(*snapshot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ TEST_F(HistogramTest, CorruptBucketBounds) {
|
|||||||
Histogram::FactoryGet("Histogram", 1, 64, 8, HistogramBase::kNoFlags));
|
Histogram::FactoryGet("Histogram", 1, 64, 8, HistogramBase::kNoFlags));
|
||||||
|
|
||||||
scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
|
scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
|
||||||
EXPECT_EQ(Histogram::NO_INCONSISTENCIES,
|
EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
|
||||||
histogram->FindCorruption(*snapshot));
|
histogram->FindCorruption(*snapshot));
|
||||||
|
|
||||||
BucketRanges* bucket_ranges =
|
BucketRanges* bucket_ranges =
|
||||||
@@ -346,8 +346,9 @@ TEST_F(HistogramTest, CorruptBucketBounds) {
|
|||||||
HistogramBase::Sample tmp = bucket_ranges->range(1);
|
HistogramBase::Sample tmp = bucket_ranges->range(1);
|
||||||
bucket_ranges->set_range(1, bucket_ranges->range(2));
|
bucket_ranges->set_range(1, bucket_ranges->range(2));
|
||||||
bucket_ranges->set_range(2, tmp);
|
bucket_ranges->set_range(2, tmp);
|
||||||
EXPECT_EQ(Histogram::BUCKET_ORDER_ERROR | Histogram::RANGE_CHECKSUM_ERROR,
|
EXPECT_EQ(
|
||||||
histogram->FindCorruption(*snapshot));
|
HistogramBase::BUCKET_ORDER_ERROR | HistogramBase::RANGE_CHECKSUM_ERROR,
|
||||||
|
histogram->FindCorruption(*snapshot));
|
||||||
|
|
||||||
bucket_ranges->set_range(2, bucket_ranges->range(1));
|
bucket_ranges->set_range(2, bucket_ranges->range(1));
|
||||||
bucket_ranges->set_range(1, tmp);
|
bucket_ranges->set_range(1, tmp);
|
||||||
@@ -355,11 +356,11 @@ TEST_F(HistogramTest, CorruptBucketBounds) {
|
|||||||
|
|
||||||
// Show that two simple changes don't offset each other
|
// Show that two simple changes don't offset each other
|
||||||
bucket_ranges->set_range(3, bucket_ranges->range(3) + 1);
|
bucket_ranges->set_range(3, bucket_ranges->range(3) + 1);
|
||||||
EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR,
|
EXPECT_EQ(HistogramBase::RANGE_CHECKSUM_ERROR,
|
||||||
histogram->FindCorruption(*snapshot));
|
histogram->FindCorruption(*snapshot));
|
||||||
|
|
||||||
bucket_ranges->set_range(4, bucket_ranges->range(4) - 1);
|
bucket_ranges->set_range(4, bucket_ranges->range(4) - 1);
|
||||||
EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR,
|
EXPECT_EQ(HistogramBase::RANGE_CHECKSUM_ERROR,
|
||||||
histogram->FindCorruption(*snapshot));
|
histogram->FindCorruption(*snapshot));
|
||||||
|
|
||||||
// Repair histogram so that destructor won't DCHECK().
|
// Repair histogram so that destructor won't DCHECK().
|
||||||
|
@@ -19,9 +19,16 @@ typedef HistogramBase::Sample Sample;
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) {
|
HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) {
|
||||||
// TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder.
|
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||||
HistogramBase* histogram = new SparseHistogram(name);
|
|
||||||
histogram->SetFlags(flags);
|
if (!histogram) {
|
||||||
|
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||||
|
HistogramBase* tentative_histogram = new SparseHistogram(name);
|
||||||
|
tentative_histogram->SetFlags(flags);
|
||||||
|
histogram =
|
||||||
|
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||||
|
}
|
||||||
|
DCHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType());
|
||||||
return histogram;
|
return histogram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,8 @@ bool StatisticsRecorder::IsActive() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) {
|
HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate(
|
||||||
|
HistogramBase* histogram) {
|
||||||
// As per crbug.com/79322 the histograms are intentionally leaked, so we need
|
// As per crbug.com/79322 the histograms are intentionally leaked, so we need
|
||||||
// to annotate them. Because ANNOTATE_LEAKING_OBJECT_PTR may be used only once
|
// to annotate them. Because ANNOTATE_LEAKING_OBJECT_PTR may be used only once
|
||||||
// for an object, the duplicates should not be annotated.
|
// for an object, the duplicates should not be annotated.
|
||||||
@@ -56,8 +57,8 @@ Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) {
|
|||||||
return histogram;
|
return histogram;
|
||||||
}
|
}
|
||||||
|
|
||||||
Histogram* histogram_to_delete = NULL;
|
HistogramBase* histogram_to_delete = NULL;
|
||||||
Histogram* histogram_to_return = NULL;
|
HistogramBase* histogram_to_return = NULL;
|
||||||
{
|
{
|
||||||
base::AutoLock auto_lock(*lock_);
|
base::AutoLock auto_lock(*lock_);
|
||||||
if (histograms_ == NULL) {
|
if (histograms_ == NULL) {
|
||||||
@@ -254,7 +255,7 @@ void StatisticsRecorder::GetBucketRanges(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
Histogram* StatisticsRecorder::FindHistogram(const std::string& name) {
|
HistogramBase* StatisticsRecorder::FindHistogram(const std::string& name) {
|
||||||
if (lock_ == NULL)
|
if (lock_ == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
base::AutoLock auto_lock(*lock_);
|
base::AutoLock auto_lock(*lock_);
|
||||||
|
@@ -23,12 +23,12 @@
|
|||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
class BucketRanges;
|
class BucketRanges;
|
||||||
class Histogram;
|
class HistogramBase;
|
||||||
class Lock;
|
class Lock;
|
||||||
|
|
||||||
class BASE_EXPORT StatisticsRecorder {
|
class BASE_EXPORT StatisticsRecorder {
|
||||||
public:
|
public:
|
||||||
typedef std::vector<Histogram*> Histograms;
|
typedef std::vector<HistogramBase*> Histograms;
|
||||||
|
|
||||||
// Initializes the StatisticsRecorder system.
|
// Initializes the StatisticsRecorder system.
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
@@ -40,7 +40,7 @@ class BASE_EXPORT StatisticsRecorder {
|
|||||||
// identically named histogram is already registered, then the argument
|
// identically named histogram is already registered, then the argument
|
||||||
// |histogram| will deleted. The returned value is always the registered
|
// |histogram| will deleted. The returned value is always the registered
|
||||||
// histogram (either the argument, or the pre-existing registered histogram).
|
// histogram (either the argument, or the pre-existing registered histogram).
|
||||||
static Histogram* RegisterOrDeleteDuplicate(Histogram* histogram);
|
static HistogramBase* RegisterOrDeleteDuplicate(HistogramBase* histogram);
|
||||||
|
|
||||||
// Register, or add a new BucketRanges. If an identically BucketRanges is
|
// Register, or add a new BucketRanges. If an identically BucketRanges is
|
||||||
// already registered, then the argument |ranges| will deleted. The returned
|
// already registered, then the argument |ranges| will deleted. The returned
|
||||||
@@ -68,7 +68,7 @@ class BASE_EXPORT StatisticsRecorder {
|
|||||||
|
|
||||||
// Find a histogram by name. It matches the exact name. This method is thread
|
// Find a histogram by name. It matches the exact name. This method is thread
|
||||||
// safe. It returns NULL if a matching histogram is not found.
|
// safe. It returns NULL if a matching histogram is not found.
|
||||||
static Histogram* FindHistogram(const std::string& name);
|
static HistogramBase* FindHistogram(const std::string& name);
|
||||||
|
|
||||||
static bool dump_on_exit() { return dump_on_exit_; }
|
static bool dump_on_exit() { return dump_on_exit_; }
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ class BASE_EXPORT StatisticsRecorder {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// We keep all registered histograms in a map, from name to histogram.
|
// We keep all registered histograms in a map, from name to histogram.
|
||||||
typedef std::map<std::string, Histogram*> HistogramMap;
|
typedef std::map<std::string, HistogramBase*> HistogramMap;
|
||||||
|
|
||||||
// We keep all |bucket_ranges_| in a map, from checksum to a list of
|
// We keep all |bucket_ranges_| in a map, from checksum to a list of
|
||||||
// |bucket_ranges_|. Checksum is calculated from the |ranges_| in
|
// |bucket_ranges_|. Checksum is calculated from the |ranges_| in
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
#import "chrome/browser/chrome_browser_application_mac.h"
|
#import "chrome/browser/chrome_browser_application_mac.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
using base::Histogram;
|
using base::HistogramBase;
|
||||||
using base::HistogramSamples;
|
using base::HistogramSamples;
|
||||||
using base::StatisticsRecorder;
|
using base::StatisticsRecorder;
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ TEST(ChromeApplicationMacTest, RecordException) {
|
|||||||
// We should have exactly the right number of exceptions.
|
// We should have exactly the right number of exceptions.
|
||||||
StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms);
|
StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms);
|
||||||
EXPECT_EQ(1U, histograms.size());
|
EXPECT_EQ(1U, histograms.size());
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histograms[0]->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histograms[0]->flags());
|
||||||
|
|
||||||
scoped_ptr<HistogramSamples> samples(histograms[0]->SnapshotSamples());
|
scoped_ptr<HistogramSamples> samples(histograms[0]->SnapshotSamples());
|
||||||
EXPECT_EQ(4, samples->GetCount(0));
|
EXPECT_EQ(4, samples->GetCount(0));
|
||||||
@@ -85,7 +85,9 @@ TEST(ChromeApplicationMacTest, RecordException) {
|
|||||||
EXPECT_EQ(2, samples->GetCount(3));
|
EXPECT_EQ(2, samples->GetCount(3));
|
||||||
|
|
||||||
// The unknown exceptions should end up in the overflow bucket.
|
// The unknown exceptions should end up in the overflow bucket.
|
||||||
EXPECT_EQ(kUnknownNSException + 1, histograms[0]->bucket_count());
|
EXPECT_TRUE(histograms[0]->HasConstructionArguments(1,
|
||||||
|
kUnknownNSException,
|
||||||
|
kUnknownNSException + 1));
|
||||||
EXPECT_EQ(4, samples->GetCount(kUnknownNSException));
|
EXPECT_EQ(4, samples->GetCount(kUnknownNSException));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -110,13 +110,12 @@ void ValidateHistograms(const RecordedHistogram* recorded,
|
|||||||
const RecordedHistogram& r = recorded[i];
|
const RecordedHistogram& r = recorded[i];
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
for (j = 0; j < histograms.size(); ++j) {
|
for (j = 0; j < histograms.size(); ++j) {
|
||||||
base::Histogram* histogram(histograms[j]);
|
base::HistogramBase* histogram(histograms[j]);
|
||||||
|
|
||||||
if (r.name == histogram->histogram_name()) {
|
if (r.name == histogram->histogram_name()) {
|
||||||
EXPECT_EQ(r.type, histogram->GetHistogramType());
|
EXPECT_EQ(r.type, histogram->GetHistogramType());
|
||||||
EXPECT_EQ(r.min, histogram->declared_min());
|
EXPECT_TRUE(
|
||||||
EXPECT_EQ(r.max, histogram->declared_max());
|
histogram->HasConstructionArguments(r.min, r.max, r.buckets));
|
||||||
EXPECT_EQ(r.buckets, histogram->bucket_count());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#include "testing/gmock/include/gmock/gmock.h"
|
#include "testing/gmock/include/gmock/gmock.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
using base::Histogram;
|
using base::HistogramBase;
|
||||||
using base::HistogramSamples;
|
using base::HistogramSamples;
|
||||||
|
|
||||||
namespace chrome_browser_net {
|
namespace chrome_browser_net {
|
||||||
@@ -210,8 +210,8 @@ class HttpPipeliningCompatibilityClientTest : public testing::Test {
|
|||||||
private:
|
private:
|
||||||
scoped_ptr<HistogramSamples> GetHistogram(const char* name) {
|
scoped_ptr<HistogramSamples> GetHistogram(const char* name) {
|
||||||
scoped_ptr<HistogramSamples> samples;
|
scoped_ptr<HistogramSamples> samples;
|
||||||
Histogram* cached_histogram = NULL;
|
HistogramBase* cached_histogram = NULL;
|
||||||
Histogram* current_histogram =
|
HistogramBase* current_histogram =
|
||||||
base::StatisticsRecorder::FindHistogram(name);
|
base::StatisticsRecorder::FindHistogram(name);
|
||||||
if (ContainsKey(histograms_, name)) {
|
if (ContainsKey(histograms_, name)) {
|
||||||
cached_histogram = histograms_[name];
|
cached_histogram = histograms_[name];
|
||||||
@@ -238,12 +238,12 @@ class HttpPipeliningCompatibilityClientTest : public testing::Test {
|
|||||||
return samples.Pass();
|
return samples.Pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::map<std::string, Histogram*> histograms_;
|
static std::map<std::string, HistogramBase*> histograms_;
|
||||||
std::map<std::string, HistogramSamples*> original_samples_;
|
std::map<std::string, HistogramSamples*> original_samples_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// static
|
// static
|
||||||
std::map<std::string, Histogram*>
|
std::map<std::string, HistogramBase*>
|
||||||
HttpPipeliningCompatibilityClientTest::histograms_;
|
HttpPipeliningCompatibilityClientTest::histograms_;
|
||||||
|
|
||||||
TEST_F(HttpPipeliningCompatibilityClientTest, Success) {
|
TEST_F(HttpPipeliningCompatibilityClientTest, Success) {
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
#include "base/utf_string_conversions.h"
|
#include "base/utf_string_conversions.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
using base::Histogram;
|
using base::HistogramBase;
|
||||||
using base::HistogramSamples;
|
using base::HistogramSamples;
|
||||||
using base::StatisticsRecorder;
|
using base::StatisticsRecorder;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ class SpellcheckHostMetricsTest : public testing::Test {
|
|||||||
|
|
||||||
TEST_F(SpellcheckHostMetricsTest, RecordEnabledStats) {
|
TEST_F(SpellcheckHostMetricsTest, RecordEnabledStats) {
|
||||||
scoped_ptr<HistogramSamples> baseline;
|
scoped_ptr<HistogramSamples> baseline;
|
||||||
Histogram* histogram =
|
HistogramBase* histogram =
|
||||||
StatisticsRecorder::FindHistogram("SpellCheck.Enabled");
|
StatisticsRecorder::FindHistogram("SpellCheck.Enabled");
|
||||||
if (histogram)
|
if (histogram)
|
||||||
baseline = histogram->SnapshotSamples();
|
baseline = histogram->SnapshotSamples();
|
||||||
@@ -69,7 +69,7 @@ TEST_F(SpellcheckHostMetricsTest, RecordEnabledStats) {
|
|||||||
TEST_F(SpellcheckHostMetricsTest, CustomWordStats) {
|
TEST_F(SpellcheckHostMetricsTest, CustomWordStats) {
|
||||||
metrics()->RecordCustomWordCountStats(123);
|
metrics()->RecordCustomWordCountStats(123);
|
||||||
|
|
||||||
Histogram* histogram =
|
HistogramBase* histogram =
|
||||||
StatisticsRecorder::FindHistogram("SpellCheck.CustomWords");
|
StatisticsRecorder::FindHistogram("SpellCheck.CustomWords");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
scoped_ptr<HistogramSamples> baseline = histogram->SnapshotSamples();
|
scoped_ptr<HistogramSamples> baseline = histogram->SnapshotSamples();
|
||||||
@@ -102,7 +102,7 @@ TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) {
|
|||||||
// Get baselines for all affected histograms.
|
// Get baselines for all affected histograms.
|
||||||
scoped_ptr<HistogramSamples> baselines[arraysize(histogramName)];
|
scoped_ptr<HistogramSamples> baselines[arraysize(histogramName)];
|
||||||
for (size_t i = 0; i < arraysize(histogramName); ++i) {
|
for (size_t i = 0; i < arraysize(histogramName); ++i) {
|
||||||
Histogram* histogram =
|
HistogramBase* histogram =
|
||||||
StatisticsRecorder::FindHistogram(histogramName[i]);
|
StatisticsRecorder::FindHistogram(histogramName[i]);
|
||||||
if (histogram)
|
if (histogram)
|
||||||
baselines[i] = histogram->SnapshotSamples();
|
baselines[i] = histogram->SnapshotSamples();
|
||||||
@@ -114,7 +114,7 @@ TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) {
|
|||||||
// Get samples for all affected histograms.
|
// Get samples for all affected histograms.
|
||||||
scoped_ptr<HistogramSamples> samples[arraysize(histogramName)];
|
scoped_ptr<HistogramSamples> samples[arraysize(histogramName)];
|
||||||
for (size_t i = 0; i < arraysize(histogramName); ++i) {
|
for (size_t i = 0; i < arraysize(histogramName); ++i) {
|
||||||
Histogram* histogram =
|
HistogramBase* histogram =
|
||||||
StatisticsRecorder::FindHistogram(histogramName[i]);
|
StatisticsRecorder::FindHistogram(histogramName[i]);
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
samples[i] = histogram->SnapshotSamples();
|
samples[i] = histogram->SnapshotSamples();
|
||||||
@@ -128,8 +128,7 @@ TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) {
|
|||||||
TEST_F(SpellcheckHostMetricsTest, RecordSpellingServiceStats) {
|
TEST_F(SpellcheckHostMetricsTest, RecordSpellingServiceStats) {
|
||||||
const char kMetricName[] = "SpellCheck.SpellingService.Enabled";
|
const char kMetricName[] = "SpellCheck.SpellingService.Enabled";
|
||||||
scoped_ptr<HistogramSamples> baseline;
|
scoped_ptr<HistogramSamples> baseline;
|
||||||
Histogram* histogram =
|
HistogramBase* histogram = StatisticsRecorder::FindHistogram(kMetricName);
|
||||||
StatisticsRecorder::FindHistogram(kMetricName);
|
|
||||||
if (histogram)
|
if (histogram)
|
||||||
baseline = histogram->SnapshotSamples();
|
baseline = histogram->SnapshotSamples();
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#include "content/public/common/password_form.h"
|
#include "content/public/common/password_form.h"
|
||||||
#include "testing/gtest_mac.h"
|
#include "testing/gtest_mac.h"
|
||||||
|
|
||||||
using base::Histogram;
|
using base::HistogramBase;
|
||||||
using base::HistogramSamples;
|
using base::HistogramSamples;
|
||||||
using base::StatisticsRecorder;
|
using base::StatisticsRecorder;
|
||||||
|
|
||||||
@@ -34,7 +34,8 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest {
|
|||||||
|
|
||||||
generator_.reset(new autofill::PasswordGenerator(20));
|
generator_.reset(new autofill::PasswordGenerator(20));
|
||||||
|
|
||||||
Histogram* histogram = StatisticsRecorder::FindHistogram(kHistogramName);
|
HistogramBase* histogram =
|
||||||
|
StatisticsRecorder::FindHistogram(kHistogramName);
|
||||||
if (histogram)
|
if (histogram)
|
||||||
original_ = histogram->SnapshotSamples();
|
original_ = histogram->SnapshotSamples();
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HistogramSamples* GetHistogramSamples() {
|
HistogramSamples* GetHistogramSamples() {
|
||||||
Histogram* histogram =
|
HistogramBase* histogram =
|
||||||
StatisticsRecorder::FindHistogram(kHistogramName);
|
StatisticsRecorder::FindHistogram(kHistogramName);
|
||||||
if (histogram) {
|
if (histogram) {
|
||||||
current_ = histogram->SnapshotSamples();
|
current_ = histogram->SnapshotSamples();
|
||||||
|
@@ -43,15 +43,15 @@ void MetricsServiceBase::RecordDelta(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MetricsServiceBase::InconsistencyDetected(
|
void MetricsServiceBase::InconsistencyDetected(
|
||||||
Histogram::Inconsistencies problem) {
|
base::HistogramBase::Inconsistency problem) {
|
||||||
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowser",
|
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowser",
|
||||||
problem, Histogram::NEVER_EXCEEDED_VALUE);
|
problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetricsServiceBase::UniqueInconsistencyDetected(
|
void MetricsServiceBase::UniqueInconsistencyDetected(
|
||||||
Histogram::Inconsistencies problem) {
|
base::HistogramBase::Inconsistency problem) {
|
||||||
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique",
|
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique",
|
||||||
problem, Histogram::NEVER_EXCEEDED_VALUE);
|
problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetricsServiceBase::InconsistencyDetectedInLoggedCount(int amount) {
|
void MetricsServiceBase::InconsistencyDetectedInLoggedCount(int amount) {
|
||||||
|
@@ -24,9 +24,9 @@ class MetricsServiceBase : public base::HistogramFlattener {
|
|||||||
virtual void RecordDelta(const base::HistogramBase& histogram,
|
virtual void RecordDelta(const base::HistogramBase& histogram,
|
||||||
const base::HistogramSamples& snapshot) OVERRIDE;
|
const base::HistogramSamples& snapshot) OVERRIDE;
|
||||||
virtual void InconsistencyDetected(
|
virtual void InconsistencyDetected(
|
||||||
base::Histogram::Inconsistencies problem) OVERRIDE;
|
base::HistogramBase::Inconsistency problem) OVERRIDE;
|
||||||
virtual void UniqueInconsistencyDetected(
|
virtual void UniqueInconsistencyDetected(
|
||||||
base::Histogram::Inconsistencies problem) OVERRIDE;
|
base::HistogramBase::Inconsistency problem) OVERRIDE;
|
||||||
virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
|
virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -113,7 +113,7 @@ void OnInitialPageLoadComplete() {
|
|||||||
|
|
||||||
// Set UMA flag for histograms outside chrome/ that can't use the
|
// Set UMA flag for histograms outside chrome/ that can't use the
|
||||||
// ScopedSlowStartupUMA class.
|
// ScopedSlowStartupUMA class.
|
||||||
base::Histogram* histogram =
|
base::HistogramBase* histogram =
|
||||||
base::StatisticsRecorder::FindHistogram("Startup.SlowStartupNSSInit");
|
base::StatisticsRecorder::FindHistogram("Startup.SlowStartupNSSInit");
|
||||||
if (histogram)
|
if (histogram)
|
||||||
histogram->SetFlags(base::HistogramBase::kUmaTargetedHistogramFlag);
|
histogram->SetFlags(base::HistogramBase::kUmaTargetedHistogramFlag);
|
||||||
|
@@ -32,8 +32,9 @@ void UMAHistogramHelper::ExpectUniqueSample(
|
|||||||
const std::string& name,
|
const std::string& name,
|
||||||
base::HistogramBase::Sample sample,
|
base::HistogramBase::Sample sample,
|
||||||
base::HistogramBase::Count expected_count) {
|
base::HistogramBase::Count expected_count) {
|
||||||
base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
|
base::HistogramBase* histogram =
|
||||||
EXPECT_NE(static_cast<base::Histogram*>(NULL), histogram)
|
base::StatisticsRecorder::FindHistogram(name);
|
||||||
|
EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram)
|
||||||
<< "Histogram \"" << name << "\" does not exist.";
|
<< "Histogram \"" << name << "\" does not exist.";
|
||||||
|
|
||||||
if (histogram) {
|
if (histogram) {
|
||||||
@@ -46,8 +47,9 @@ void UMAHistogramHelper::ExpectUniqueSample(
|
|||||||
void UMAHistogramHelper::ExpectTotalCount(
|
void UMAHistogramHelper::ExpectTotalCount(
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
base::HistogramBase::Count count) {
|
base::HistogramBase::Count count) {
|
||||||
base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
|
base::HistogramBase* histogram =
|
||||||
EXPECT_NE(static_cast<base::Histogram*>(NULL), histogram)
|
base::StatisticsRecorder::FindHistogram(name);
|
||||||
|
EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram)
|
||||||
<< "Histogram \"" << name << "\" does not exist.";
|
<< "Histogram \"" << name << "\" does not exist.";
|
||||||
|
|
||||||
if (histogram) {
|
if (histogram) {
|
||||||
|
@@ -63,7 +63,8 @@ void HistogramMessageFilter::OnGetBrowserHistogram(
|
|||||||
<< " switches.";
|
<< " switches.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
|
base::HistogramBase* histogram =
|
||||||
|
base::StatisticsRecorder::FindHistogram(name);
|
||||||
if (!histogram) {
|
if (!histogram) {
|
||||||
*histogram_json = "{}";
|
*histogram_json = "{}";
|
||||||
} else {
|
} else {
|
||||||
|
@@ -87,15 +87,15 @@ void ChildHistogramMessageFilter::RecordDelta(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChildHistogramMessageFilter::InconsistencyDetected(
|
void ChildHistogramMessageFilter::InconsistencyDetected(
|
||||||
base::Histogram::Inconsistencies problem) {
|
base::HistogramBase::Inconsistency problem) {
|
||||||
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcess",
|
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcess",
|
||||||
problem, base::Histogram::NEVER_EXCEEDED_VALUE);
|
problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChildHistogramMessageFilter::UniqueInconsistencyDetected(
|
void ChildHistogramMessageFilter::UniqueInconsistencyDetected(
|
||||||
base::Histogram::Inconsistencies problem) {
|
base::HistogramBase::Inconsistency problem) {
|
||||||
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcessUnique",
|
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcessUnique",
|
||||||
problem, base::Histogram::NEVER_EXCEEDED_VALUE);
|
problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChildHistogramMessageFilter::InconsistencyDetectedInLoggedCount(
|
void ChildHistogramMessageFilter::InconsistencyDetectedInLoggedCount(
|
||||||
|
@@ -38,9 +38,9 @@ class ChildHistogramMessageFilter : public base::HistogramFlattener,
|
|||||||
virtual void RecordDelta(const base::HistogramBase& histogram,
|
virtual void RecordDelta(const base::HistogramBase& histogram,
|
||||||
const base::HistogramSamples& snapshot) OVERRIDE;
|
const base::HistogramSamples& snapshot) OVERRIDE;
|
||||||
virtual void InconsistencyDetected(
|
virtual void InconsistencyDetected(
|
||||||
base::Histogram::Inconsistencies problem) OVERRIDE;
|
base::HistogramBase::Inconsistency problem) OVERRIDE;
|
||||||
virtual void UniqueInconsistencyDetected(
|
virtual void UniqueInconsistencyDetected(
|
||||||
base::Histogram::Inconsistencies problem) OVERRIDE;
|
base::HistogramBase::Inconsistency problem) OVERRIDE;
|
||||||
virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
|
virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -183,7 +183,7 @@ void DomAutomationController::GetHistogram(const CppArgumentList& args,
|
|||||||
result->SetNull();
|
result->SetNull();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base::Histogram* histogram =
|
base::HistogramBase* histogram =
|
||||||
base::StatisticsRecorder::FindHistogram(args[0].ToString());
|
base::StatisticsRecorder::FindHistogram(args[0].ToString());
|
||||||
std::string output;
|
std::string output;
|
||||||
if (!histogram) {
|
if (!histogram) {
|
||||||
|
@@ -182,7 +182,7 @@ TEST_F(SignalSenderVerificationTest, TestSignalAccepted) {
|
|||||||
TEST_F(SignalSenderVerificationTest, TestSignalRejected) {
|
TEST_F(SignalSenderVerificationTest, TestSignalRejected) {
|
||||||
// To make sure the histogram instance is created.
|
// To make sure the histogram instance is created.
|
||||||
UMA_HISTOGRAM_COUNTS("DBus.RejectedSignalCount", 0);
|
UMA_HISTOGRAM_COUNTS("DBus.RejectedSignalCount", 0);
|
||||||
base::Histogram* reject_signal_histogram =
|
base::HistogramBase* reject_signal_histogram =
|
||||||
base::StatisticsRecorder::FindHistogram("DBus.RejectedSignalCount");
|
base::StatisticsRecorder::FindHistogram("DBus.RejectedSignalCount");
|
||||||
scoped_ptr<base::HistogramSamples> samples1(
|
scoped_ptr<base::HistogramSamples> samples1(
|
||||||
reject_signal_histogram->SnapshotSamples());
|
reject_signal_histogram->SnapshotSamples());
|
||||||
|
@@ -45,7 +45,7 @@ StatsHistogram* StatsHistogram::FactoryGet(const std::string& name,
|
|||||||
Sample minimum = 1;
|
Sample minimum = 1;
|
||||||
Sample maximum = disk_cache::Stats::kDataSizesLength - 1;
|
Sample maximum = disk_cache::Stats::kDataSizesLength - 1;
|
||||||
size_t bucket_count = disk_cache::Stats::kDataSizesLength;
|
size_t bucket_count = disk_cache::Stats::kDataSizesLength;
|
||||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||||
if (!histogram) {
|
if (!histogram) {
|
||||||
DCHECK(stats);
|
DCHECK(stats);
|
||||||
|
|
||||||
@@ -83,9 +83,9 @@ scoped_ptr<HistogramSamples> StatsHistogram::SnapshotSamples() const {
|
|||||||
return samples.PassAs<HistogramSamples>();
|
return samples.PassAs<HistogramSamples>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Histogram::Inconsistencies StatsHistogram::FindCorruption(
|
int StatsHistogram::FindCorruption(const HistogramSamples& samples) const {
|
||||||
const HistogramSamples& samples) const {
|
// This class won't monitor inconsistencies.
|
||||||
return NO_INCONSISTENCIES; // This class won't monitor inconsistencies.
|
return HistogramBase::NO_INCONSISTENCIES;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace disk_cache
|
} // namespace disk_cache
|
||||||
|
@@ -43,7 +43,7 @@ class StatsHistogram : public base::Histogram {
|
|||||||
const Stats* stats);
|
const Stats* stats);
|
||||||
|
|
||||||
virtual scoped_ptr<base::HistogramSamples> SnapshotSamples() const OVERRIDE;
|
virtual scoped_ptr<base::HistogramSamples> SnapshotSamples() const OVERRIDE;
|
||||||
virtual Inconsistencies FindCorruption(
|
virtual int FindCorruption(
|
||||||
const base::HistogramSamples& samples) const OVERRIDE;
|
const base::HistogramSamples& samples) const OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include "testing/platform_test.h"
|
#include "testing/platform_test.h"
|
||||||
|
|
||||||
using base::Histogram;
|
using base::Histogram;
|
||||||
|
using base::HistogramBase;
|
||||||
using base::HistogramSamples;
|
using base::HistogramSamples;
|
||||||
using base::StatisticsRecorder;
|
using base::StatisticsRecorder;
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ TEST(SocketStreamMetricsTest, ProtocolType) {
|
|||||||
// as histograms can get affected by other tests. In particular,
|
// as histograms can get affected by other tests. In particular,
|
||||||
// SocketStreamTest and WebSocketTest can affect the histograms.
|
// SocketStreamTest and WebSocketTest can affect the histograms.
|
||||||
scoped_ptr<HistogramSamples> original;
|
scoped_ptr<HistogramSamples> original;
|
||||||
Histogram* histogram =
|
HistogramBase* histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ProtocolType");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.ProtocolType");
|
||||||
if (histogram) {
|
if (histogram) {
|
||||||
original = histogram->SnapshotSamples();
|
original = histogram->SnapshotSamples();
|
||||||
@@ -40,7 +41,7 @@ TEST(SocketStreamMetricsTest, ProtocolType) {
|
|||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ProtocolType");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.ProtocolType");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
|
|
||||||
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
||||||
if (original.get()) {
|
if (original.get()) {
|
||||||
@@ -55,7 +56,7 @@ TEST(SocketStreamMetricsTest, ProtocolType) {
|
|||||||
TEST(SocketStreamMetricsTest, ConnectionType) {
|
TEST(SocketStreamMetricsTest, ConnectionType) {
|
||||||
// First we'll preserve the original values.
|
// First we'll preserve the original values.
|
||||||
scoped_ptr<HistogramSamples> original;
|
scoped_ptr<HistogramSamples> original;
|
||||||
Histogram* histogram =
|
HistogramBase* histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionType");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionType");
|
||||||
if (histogram) {
|
if (histogram) {
|
||||||
original = histogram->SnapshotSamples();
|
original = histogram->SnapshotSamples();
|
||||||
@@ -75,7 +76,7 @@ TEST(SocketStreamMetricsTest, ConnectionType) {
|
|||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionType");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionType");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
|
|
||||||
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
||||||
if (original.get()) {
|
if (original.get()) {
|
||||||
@@ -90,7 +91,7 @@ TEST(SocketStreamMetricsTest, ConnectionType) {
|
|||||||
TEST(SocketStreamMetricsTest, WireProtocolType) {
|
TEST(SocketStreamMetricsTest, WireProtocolType) {
|
||||||
// First we'll preserve the original values.
|
// First we'll preserve the original values.
|
||||||
scoped_ptr<HistogramSamples> original;
|
scoped_ptr<HistogramSamples> original;
|
||||||
Histogram* histogram =
|
HistogramBase* histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.WireProtocolType");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.WireProtocolType");
|
||||||
if (histogram) {
|
if (histogram) {
|
||||||
original = histogram->SnapshotSamples();
|
original = histogram->SnapshotSamples();
|
||||||
@@ -106,7 +107,7 @@ TEST(SocketStreamMetricsTest, WireProtocolType) {
|
|||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.WireProtocolType");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.WireProtocolType");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
|
|
||||||
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
||||||
if (original.get()) {
|
if (original.get()) {
|
||||||
@@ -125,7 +126,7 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
|||||||
|
|
||||||
scoped_ptr<HistogramSamples> original;
|
scoped_ptr<HistogramSamples> original;
|
||||||
|
|
||||||
Histogram* histogram =
|
HistogramBase* histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedBytes");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedBytes");
|
||||||
if (histogram) {
|
if (histogram) {
|
||||||
original = histogram->SnapshotSamples();
|
original = histogram->SnapshotSamples();
|
||||||
@@ -167,28 +168,28 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
|||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionLatency");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionLatency");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
// We don't check the contents of the histogram as it's time sensitive.
|
// We don't check the contents of the histogram as it's time sensitive.
|
||||||
|
|
||||||
// ConnectionEstablish.
|
// ConnectionEstablish.
|
||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionEstablish");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionEstablish");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
// We don't check the contents of the histogram as it's time sensitive.
|
// We don't check the contents of the histogram as it's time sensitive.
|
||||||
|
|
||||||
// Duration.
|
// Duration.
|
||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.Duration");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.Duration");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
// We don't check the contents of the histogram as it's time sensitive.
|
// We don't check the contents of the histogram as it's time sensitive.
|
||||||
|
|
||||||
// ReceivedBytes.
|
// ReceivedBytes.
|
||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedBytes");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedBytes");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
samples = histogram->SnapshotSamples();
|
samples = histogram->SnapshotSamples();
|
||||||
EXPECT_EQ(11, samples->sum() - original_received_bytes); // 11 bytes read.
|
EXPECT_EQ(11, samples->sum() - original_received_bytes); // 11 bytes read.
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
|||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedCounts");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedCounts");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
samples = histogram->SnapshotSamples();
|
samples = histogram->SnapshotSamples();
|
||||||
EXPECT_EQ(2, samples->sum() - original_received_counts); // 2 read requests.
|
EXPECT_EQ(2, samples->sum() - original_received_counts); // 2 read requests.
|
||||||
|
|
||||||
@@ -204,7 +205,7 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
|||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.SentBytes");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.SentBytes");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
samples = histogram->SnapshotSamples();
|
samples = histogram->SnapshotSamples();
|
||||||
EXPECT_EQ(222, samples->sum() - original_sent_bytes); // 222 bytes sent.
|
EXPECT_EQ(222, samples->sum() - original_sent_bytes); // 222 bytes sent.
|
||||||
|
|
||||||
@@ -212,7 +213,7 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
|||||||
histogram =
|
histogram =
|
||||||
StatisticsRecorder::FindHistogram("Net.SocketStream.SentCounts");
|
StatisticsRecorder::FindHistogram("Net.SocketStream.SentCounts");
|
||||||
ASSERT_TRUE(histogram != NULL);
|
ASSERT_TRUE(histogram != NULL);
|
||||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
samples = histogram->SnapshotSamples();
|
samples = histogram->SnapshotSamples();
|
||||||
EXPECT_EQ(3, samples->sum() - original_sent_counts); // 3 write requests.
|
EXPECT_EQ(3, samples->sum() - original_sent_counts); // 3 write requests.
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@ namespace net {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using base::Histogram;
|
using base::Histogram;
|
||||||
|
using base::HistogramBase;
|
||||||
using base::HistogramSamples;
|
using base::HistogramSamples;
|
||||||
using base::StatisticsRecorder;
|
using base::StatisticsRecorder;
|
||||||
|
|
||||||
@@ -211,7 +212,7 @@ void URLRequestThrottlerEntryTest::SetUp() {
|
|||||||
// Must retrieve original samples for each histogram for comparison
|
// Must retrieve original samples for each histogram for comparison
|
||||||
// as other tests may affect them.
|
// as other tests may affect them.
|
||||||
const char* name = kHistogramNames[i];
|
const char* name = kHistogramNames[i];
|
||||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||||
if (histogram) {
|
if (histogram) {
|
||||||
original_samples_[name] = histogram->SnapshotSamples().release();
|
original_samples_[name] = histogram->SnapshotSamples().release();
|
||||||
} else {
|
} else {
|
||||||
@@ -230,9 +231,9 @@ void URLRequestThrottlerEntryTest::CalculateHistogramDeltas() {
|
|||||||
const char* name = kHistogramNames[i];
|
const char* name = kHistogramNames[i];
|
||||||
HistogramSamples* original = original_samples_[name];
|
HistogramSamples* original = original_samples_[name];
|
||||||
|
|
||||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||||
if (histogram) {
|
if (histogram) {
|
||||||
ASSERT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
ASSERT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||||
|
|
||||||
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
||||||
if (original)
|
if (original)
|
||||||
|
Reference in New Issue
Block a user