Reviewers: Jakob,

Description:
Mark timed range in the profile plot.

[email protected]

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

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

Affected files (+31, -1 lines):
  M src/log.h
  M src/log.cc
  M src/runtime.cc
  M tools/profviz/composer.js


Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index f6dfd2161d89b425c89b97f741acf8a3160b3a05..a916482283fd5653de7d32260f7043363aa67ea9 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -1084,6 +1084,16 @@ void Logger::CodeDeoptEvent(Code* code) {
 }


+void Logger::CurrentTimeEvent() {
+  if (!log_->IsEnabled()) return;
+  ASSERT(FLAG_log_internal_timer_events);
+  Log::MessageBuilder msg(log_);
+  int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds());
+  msg.Append("current-time,%ld\n", since_epoch);
+  msg.WriteToLogFile();
+}
+
+
 void Logger::TimerEvent(StartEnd se, const char* name) {
   if (!log_->IsEnabled()) return;
   ASSERT(FLAG_log_internal_timer_events);
Index: src/log.h
diff --git a/src/log.h b/src/log.h
index 68e0a6cb6eeb03e4b46162fba639dbc27d7ff5d2..739a77445599a16ca6d8b185a015f4c91fce75b5 100644
--- a/src/log.h
+++ b/src/log.h
@@ -291,6 +291,7 @@ class Logger {
   enum StartEnd { START, END };

   void CodeDeoptEvent(Code* code);
+  void CurrentTimeEvent();

   void TimerEvent(StartEnd se, const char* name);

Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 13a45d532ebbca1b14fa55d499c8330e87074414..d5903a0645012edf955edc56434add451425e40a 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -9636,6 +9636,7 @@ RUNTIME_FUNCTION(Runtime_DebugTrace) {
 RUNTIME_FUNCTION(Runtime_DateCurrentTime) {
   HandleScope scope(isolate);
   ASSERT(args.length() == 0);
+  if (FLAG_log_timer_events) LOG(isolate, CurrentTimeEvent());

   // According to ECMA-262, section 15.9.1, page 117, the precision of
   // the number in a Date object representing a particular instant in
Index: tools/profviz/composer.js
diff --git a/tools/profviz/composer.js b/tools/profviz/composer.js
index 8c187e58cb122949d5d2234be651f73f333ecc2d..0520472c5f71431ea186be4f5d20e6314bf86325 100644
--- a/tools/profviz/composer.js
+++ b/tools/profviz/composer.js
@@ -43,6 +43,7 @@ function PlotScriptComposer(kResX, kResY, error_output) {

var kY1Offset = 11; // Offset for stack frame vs. event lines.
   var kDeoptRow = 7;                // Row displaying deopts.
+ var kGetTimeHeight = 0.5; // Height of marker displaying timed part.
   var kMaxDeoptLength = 4;          // Draw size of the largest deopt.
   var kPauseLabelPadding = 5;       // Padding for pause time labels.
   var kNumPauseLabels = 7;          // Number of biggest pauses to label.
@@ -136,6 +137,7 @@ function PlotScriptComposer(kResX, kResY, error_output) {
   var code_map = new CodeMap();
   var execution_pauses = [];
   var deopts = [];
+  var gettime = [];
   var event_stack = [];
   var last_time_stamp = [];
   for (var i = 0; i < kNumThreads; i++) {
@@ -274,6 +276,10 @@ function PlotScriptComposer(kResX, kResY, error_output) {
       deopts.push(new Deopt(time, size));
     }

+    var processCurrentTimeEvent = function(time) {
+      gettime.push(time);
+    }
+
     var processSharedLibrary = function(name, start, end) {
       var code_entry = new CodeMap.CodeEntry(end - start, name);
       code_entry.kind = -3;  // External code kind.
@@ -316,6 +322,8 @@ function PlotScriptComposer(kResX, kResY, error_output) {
                             processor: processCodeDeleteEvent },
         'code-deopt':     { parsers: [parseTimeStamp, parseInt],
                             processor: processCodeDeoptEvent },
+        'current-time':   { parsers: [parseTimeStamp],
+                            processor: processCurrentTimeEvent },
         'tick':           { parsers: [parseInt, parseTimeStamp,
                                       null, null, parseInt, 'var-args'],
                             processor: processTickEvent }
@@ -391,12 +399,15 @@ function PlotScriptComposer(kResX, kResY, error_output) {
     output("set xtics out nomirror");
     output("unset key");

-    function DrawBarBase(color, start, end, top, bottom) {
+    function DrawBarBase(color, start, end, top, bottom, transparency) {
       obj_index++;
       command = "set object " + obj_index + " rect";
       command += " from " + start + ", " + top;
       command += " to " + end + ", " + bottom;
       command += " fc rgb \"" + color + "\"";
+      if (transparency) {
+        command += " fs transparent solid " + transparency;
+      }
       output(command);
     }

@@ -430,6 +441,13 @@ function PlotScriptComposer(kResX, kResY, error_output) {
                   deopt.size / max_deopt_size * kMaxDeoptLength);
     }

+    // Plot current time polls.
+    if (gettime.length > 1) {
+      var start = gettime[0];
+      var end = gettime.pop();
+      DrawBarBase("#0000BB", start, end, kGetTimeHeight, 0, 0.2);
+    }
+
     // Name Y-axis.
     var ytics = [];
     for (name in TimerEvents) {


--
--
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