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

Unified Diff: src/counters.cc

Issue 42020: - Added ability to call histograms from within v8... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 | « src/counters.h ('k') | src/heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/counters.cc
===================================================================
--- src/counters.cc (revision 1503)
+++ src/counters.cc (working copy)
@@ -33,6 +33,8 @@
namespace v8 { namespace internal {
CounterLookupCallback StatsTable::lookup_function_ = NULL;
+CreateHistogramCallback StatsTable::create_histogram_function_ = NULL;
+AddHistogramSampleCallback StatsTable::add_histogram_sample_function_ = NULL;
// Start the timer.
void StatsCounterTimer::Start() {
@@ -53,4 +55,23 @@
counter_.Increment(milliseconds);
}
+// Start the timer.
+void HistogramTimer::Start() {
+ if (GetHistogram() != NULL) {
+ stop_time_ = 0;
+ start_time_ = OS::Ticks();
+ }
+}
+
+// Stop the timer and record the results.
+void HistogramTimer::Stop() {
+ if (histogram_ != NULL) {
+ stop_time_ = OS::Ticks();
+
+ // Compute the delta between start and stop, in milliseconds.
+ int milliseconds = static_cast<int>(stop_time_ - start_time_) / 1000;
+ StatsTable::AddHistogramSample(histogram_, milliseconds);
+ }
+}
+
} } // namespace v8::internal
« no previous file with comments | « src/counters.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698