Reviewers: Hannes Payer,

Message:
PTAL

Description:
Add event statistics to GCTracer.

- Add method to GCTracer to compute mean and max of the last few
  Scavenger, Mark Compactor and Incremental Marking events.

[email protected]
BUG=

Please review this at https://codereview.chromium.org/410413005/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+80, -0 lines):
  M src/gc-tracer.h
  M src/gc-tracer.cc


Index: src/gc-tracer.cc
diff --git a/src/gc-tracer.cc b/src/gc-tracer.cc
index 86743cda23fa33a10da3c949ac3282a710ec52cc..3b381b3ad9c0c4b1843311edbc57122a1a526da0 100644
--- a/src/gc-tracer.cc
+++ b/src/gc-tracer.cc
@@ -268,5 +268,50 @@ void GCTracer::PrintNVP() const {

   PrintF("\n");
 }
+
+
+double GCTracer::MeanDuration(const EventBuffer& events) const {
+  if (events.empty()) return 0.0;
+
+  double mean = 0.0;
+  EventBuffer::const_iterator iter = events.begin();
+  while (iter != events.end()) {
+    mean += iter->end_time - iter->start_time;
+    ++iter;
+  }
+
+  return mean / events.size();
+}
+
+
+double GCTracer::MaxDuration(const EventBuffer& events) const {
+  if (events.empty()) return 0.0;
+
+  double maximum = 0.0f;
+  EventBuffer::const_iterator iter = events.begin();
+  while (iter != events.end()) {
+    maximum = Max(iter->end_time - iter->start_time, maximum);
+    ++iter;
+  }
+
+  return maximum;
+}
+
+
+double GCTracer::MeanIncrementalMarkingDuration() const {
+  if (mark_compactor_events_.empty()) return 0.0;
+
+  EventBuffer::const_iterator last_mc = mark_compactor_events_.begin();
+  return last_mc->incremental_marking_duration /
+         last_mc->incremental_marking_steps;
+}
+
+
+double GCTracer::MaxIncrementalMarkingDuration() const {
+  if (mark_compactor_events_.empty()) return 0.0;
+
+  EventBuffer::const_iterator last_mc = mark_compactor_events_.begin();
+  return last_mc->longest_incremental_marking_step;
+}
 }
 }  // namespace v8::internal
Index: src/gc-tracer.h
diff --git a/src/gc-tracer.h b/src/gc-tracer.h
index a9e02b3118daabca29bc07174d17d43c2ae223db..db10d28cfc4257840ae96b123aec44df59ac2989 100644
--- a/src/gc-tracer.h
+++ b/src/gc-tracer.h
@@ -202,6 +202,35 @@ class GCTracer BASE_EMBEDDED {
   // Log an incremental marking step.
   void AddIncrementalMarkingStep(double duration);

+  // Compute the mean duration of the last scavenger events.
+  double MeanScavengerDuration() const {
+    return MeanDuration(scavenger_events_);
+  }
+
+  // Compute the max duratino of the last scavenger events. Returns 0 if no
+  // events have been recorded.
+ double MaxScavengerDuration() const { return MaxDuration(scavenger_events_); }
+
+ // Compute the mean duration of the last mark compactor events. Returns 0 if
+  // no events have been recorded.
+  double MeanMarkCompactorDuration() const {
+    return MeanDuration(mark_compactor_events_);
+  }
+
+ // Compute the max duration of the last mark compactor events. Return 0 if no
+  // events have been recorded.
+  double MaxMarkCompactorDuration() const {
+    return MaxDuration(mark_compactor_events_);
+  }
+
+  // Compute the mean step duration of the last incremental marking round.
+  // Returns 0 if no incremental marking round has been completed.
+  double MeanIncrementalMarkingDuration() const;
+
+  // Compute the max step duration of the last incremental marking round.
+  // Returns 0 if no incremental marking round has been completed.
+  double MaxIncrementalMarkingDuration() const;
+
  private:
   // Print one detailed trace line in name=value format.
   // TODO(ernstm): Move to Heap.
@@ -211,6 +240,12 @@ class GCTracer BASE_EMBEDDED {
   // TODO(ernstm): Move to Heap.
   void Print() const;

+  // Compute the mean duration of the events in the given ring buffer.
+  double MeanDuration(const EventBuffer& events) const;
+
+  // Compute the max duration of the events in the given ring buffer.
+  double MaxDuration(const EventBuffer& events) const;
+
   // Pointer to the heap that owns this tracer.
   Heap* heap_;



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to