diff options
author | Ian Rogers <irogers@google.com> | 2013-11-14 17:49:12 -0800 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2013-11-14 17:49:12 -0800 |
commit | 500793f33b8af8bc7ccf5595a66b4b13bce766bc (patch) | |
tree | b45e15242692d64646c3ef09e555106cb61b8040 /runtime/base | |
parent | f44e87fcf2f9cdf5e7e623dce667e2472c8d830e (diff) | |
download | art-500793f33b8af8bc7ccf5595a66b4b13bce766bc.zip art-500793f33b8af8bc7ccf5595a66b4b13bce766bc.tar.gz art-500793f33b8af8bc7ccf5595a66b4b13bce766bc.tar.bz2 |
LEB128 tests and performance measurements.
Change-Id: I1850a2ff9225cfab8f896619c212b1b55f03ae94
Diffstat (limited to 'runtime/base')
-rw-r--r-- | runtime/base/histogram-inl.h | 18 | ||||
-rw-r--r-- | runtime/base/histogram.h | 2 | ||||
-rw-r--r-- | runtime/base/histogram_test.cc | 22 | ||||
-rw-r--r-- | runtime/base/timing_logger.cc | 2 |
4 files changed, 22 insertions, 22 deletions
diff --git a/runtime/base/histogram-inl.h b/runtime/base/histogram-inl.h index 0345266..9e08ae6 100644 --- a/runtime/base/histogram-inl.h +++ b/runtime/base/histogram-inl.h @@ -170,20 +170,20 @@ inline void Histogram<Value>::PrintConfidenceIntervals(std::ostream &os, double os << FormatDuration(Max() * kAdjust, unit) << "\n"; } -template <class Value> inline void Histogram<Value>::CreateHistogram(CumulativeData& out_data) { +template <class Value> inline void Histogram<Value>::CreateHistogram(CumulativeData* out_data) { DCHECK_GT(sample_size_, 0ull); - out_data.freq_.clear(); - out_data.perc_.clear(); + out_data->freq_.clear(); + out_data->perc_.clear(); uint64_t accumulated = 0; - out_data.freq_.push_back(accumulated); - out_data.perc_.push_back(0.0); + out_data->freq_.push_back(accumulated); + out_data->perc_.push_back(0.0); for (size_t idx = 0; idx < frequency_.size(); idx++) { accumulated += frequency_[idx]; - out_data.freq_.push_back(accumulated); - out_data.perc_.push_back(static_cast<double>(accumulated) / static_cast<double>(sample_size_)); + out_data->freq_.push_back(accumulated); + out_data->perc_.push_back(static_cast<double>(accumulated) / static_cast<double>(sample_size_)); } - DCHECK_EQ(out_data.freq_.back(), sample_size_); - DCHECK_LE(std::abs(out_data.perc_.back() - 1.0), 0.001); + DCHECK_EQ(out_data->freq_.back(), sample_size_); + DCHECK_LE(std::abs(out_data->perc_.back() - 1.0), 0.001); } template <class Value> diff --git a/runtime/base/histogram.h b/runtime/base/histogram.h index 2a02cf4..e22b6e1 100644 --- a/runtime/base/histogram.h +++ b/runtime/base/histogram.h @@ -47,7 +47,7 @@ template <class Value> class Histogram { // cumulative_freq[i] = sum(frequency[j] : 0 < j < i ) // Accumulative summation of percentiles; which is the frequency / SampleSize // cumulative_perc[i] = sum(frequency[j] / SampleSize : 0 < j < i ) - void CreateHistogram(CumulativeData& data); + void CreateHistogram(CumulativeData* data); // Reset the cumulative values, next time CreateHistogram is called it will recreate the cache. void Reset(); double Mean() const; diff --git a/runtime/base/histogram_test.cc b/runtime/base/histogram_test.cc index 534440c..9d371f5 100644 --- a/runtime/base/histogram_test.cc +++ b/runtime/base/histogram_test.cc @@ -85,7 +85,7 @@ TEST(Histtest, Percentile) { hist->AddValue(145); hist->AddValue(155); - hist->CreateHistogram(data); + hist->CreateHistogram(&data); PerValue = hist->Percentile(0.50, data); EXPECT_EQ(875, static_cast<int>(PerValue * 10)); } @@ -117,7 +117,7 @@ TEST(Histtest, UpdateRange) { hist->AddValue(200); hist->AddValue(205); hist->AddValue(212); - hist->CreateHistogram(data); + hist->CreateHistogram(&data); PerValue = hist->Percentile(0.50, data); std::string text; @@ -132,7 +132,6 @@ TEST(Histtest, UpdateRange) { TEST(Histtest, Reset) { UniquePtr<Histogram<uint64_t> > hist(new Histogram<uint64_t>("Reset", 5)); - Histogram<uint64_t>::CumulativeData data; double PerValue; hist->AddValue(0); @@ -160,7 +159,8 @@ TEST(Histtest, Reset) { hist->AddValue(200); hist->AddValue(205); hist->AddValue(212); - hist->CreateHistogram(data); + Histogram<uint64_t>::CumulativeData data; + hist->CreateHistogram(&data); PerValue = hist->Percentile(0.50, data); std::string text; @@ -185,7 +185,7 @@ TEST(Histtest, MultipleCreateHist) { hist->AddValue(68); hist->AddValue(75); hist->AddValue(93); - hist->CreateHistogram(data); + hist->CreateHistogram(&data); hist->AddValue(110); hist->AddValue(121); hist->AddValue(132); @@ -194,14 +194,14 @@ TEST(Histtest, MultipleCreateHist) { hist->AddValue(155); hist->AddValue(163); hist->AddValue(168); - hist->CreateHistogram(data); + hist->CreateHistogram(&data); hist->AddValue(175); hist->AddValue(182); hist->AddValue(193); hist->AddValue(200); hist->AddValue(205); hist->AddValue(212); - hist->CreateHistogram(data); + hist->CreateHistogram(&data); PerValue = hist->Percentile(0.50, data); std::stringstream stream; std::string expected("MultipleCreateHist:\t99% C.I. 15us-212us Avg: 126.380us Max: 212us\n"); @@ -217,7 +217,7 @@ TEST(Histtest, SingleValue) { Histogram<uint64_t>::CumulativeData data; hist->AddValue(1); - hist->CreateHistogram(data); + hist->CreateHistogram(&data); std::stringstream stream; std::string expected = "SingleValue:\t99% C.I. 1us-1us Avg: 1us Max: 1us\n"; hist->PrintConfidenceIntervals(stream, 0.99, data); @@ -234,7 +234,7 @@ TEST(Histtest, CappingPercentiles) { for (uint64_t idx = 0ull; idx < 150ull; idx++) { hist->AddValue(0); } - hist->CreateHistogram(data); + hist->CreateHistogram(&data); per_995 = hist->Percentile(0.995, data); EXPECT_EQ(per_995, 0); hist->Reset(); @@ -243,7 +243,7 @@ TEST(Histtest, CappingPercentiles) { hist->AddValue(val); } } - hist->CreateHistogram(data); + hist->CreateHistogram(&data); per_005 = hist->Percentile(0.005, data); per_995 = hist->Percentile(0.995, data); EXPECT_EQ(1, per_005); @@ -260,7 +260,7 @@ TEST(Histtest, SpikyValues) { } } hist->AddValue(10000); - hist->CreateHistogram(data); + hist->CreateHistogram(&data); std::stringstream stream; std::string expected = "SpikyValues:\t99% C.I. 0.089us-2541.825us Avg: 95.033us Max: 10000us\n"; hist->PrintConfidenceIntervals(stream, 0.99, data); diff --git a/runtime/base/timing_logger.cc b/runtime/base/timing_logger.cc index dae8201..bebbd70 100644 --- a/runtime/base/timing_logger.cc +++ b/runtime/base/timing_logger.cc @@ -115,7 +115,7 @@ void CumulativeLogger::DumpHistogram(std::ostream &os) { for (CumulativeLogger::HistogramsIterator it = histograms_.begin(), end = histograms_.end(); it != end; ++it) { Histogram<uint64_t>::CumulativeData cumulative_data; - it->second->CreateHistogram(cumulative_data); + it->second->CreateHistogram(&cumulative_data); it->second->PrintConfidenceIntervals(os, 0.99, cumulative_data); // Reset cumulative values to save memory. We don't expect DumpHistogram to be called often, so // it is not performance critical. |