Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: src/counters.h

Issue 10695056: Factor out a Histogram class from HistogramTimer, and use it to measure external fragmentation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/counters.cc » ('j') | src/counters.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/counters.h
diff --git a/src/counters.h b/src/counters.h
index 6498a0242f9246a1d638bcd55f620971bf135740..f31b12db4884d5cc53b1d7cc7333eee2fbfff29f 100644
--- a/src/counters.h
+++ b/src/counters.h
@@ -199,25 +199,27 @@ struct StatsCounterTimer {
}
};
-// A HistogramTimer allows distributions of results to be created
-// HistogramTimer t = { L"foo", NULL, false, 0, 0 };
-struct HistogramTimer {
+// Similar to StatsCounter, the class Histogram represents a dynamically
Michael Starzinger 2012/07/02 21:09:56 Can we remove the reference to StatsCounter here?
jochen (gone - plz use gerrit) 2012/07/13 09:48:08 Done.
+// created histogram in the StatsTable.
+//
+// This class is designed to be POD initialized. It will be registered with
+// the histogram system on first use. For example:
+// Histogram h = { "myhist", 0, 10000, 50, NULL, false };
+struct Histogram {
const char* name_;
+ int min_;
+ int max_;
+ int num_buckets_;
void* histogram_;
bool lookup_done_;
- int64_t start_time_;
- int64_t stop_time_;
-
- // Start the timer.
- void Start();
+ // Add a single sample to this histogram.
+ void AddSample(int sample);
- // Stop the timer and record the results.
- void Stop();
-
- // Returns true if the timer is running.
- bool Running() {
- return (histogram_ != NULL) && (start_time_ != 0) && (stop_time_ == 0);
+ // Is this histogram enabled?
+ // Returns false if table is full.
Michael Starzinger 2012/07/02 21:09:56 Let's turn that into just one line: "Returns true
jochen (gone - plz use gerrit) 2012/07/13 09:48:08 Done.
+ bool Enabled() {
+ return GetHistogram() != NULL;
}
protected:
@@ -234,6 +236,26 @@ struct HistogramTimer {
void* CreateHistogram() const;
};
+// A HistogramTimer allows distributions of results to be created
+// HistogramTimer t = { {L"foo", 0, 10000, 50, NULL, false}, 0, 0 };
+struct HistogramTimer {
+ Histogram histogram_;
+
+ int64_t start_time_;
+ int64_t stop_time_;
+
+ // Start the timer.
+ void Start();
+
+ // Stop the timer and record the results.
+ void Stop();
+
+ // Returns true if the timer is running.
+ bool Running() {
+ return histogram_.Enabled() && (start_time_ != 0) && (stop_time_ == 0);
+ }
+};
+
// Helper class for scoping a HistogramTimer.
class HistogramTimerScope BASE_EMBEDDED {
public:
« no previous file with comments | « no previous file | src/counters.cc » ('j') | src/counters.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698