Commit 1c70a027 authored by caseq@chromium.org's avatar caseq@chromium.org

Timeline: fix trace event nesting computation after r175746

BUG=

Review URL: https://codereview.chromium.org/322763002

git-svn-id: svn://svn.chromium.org/blink/trunk@175791 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 80bd4516
...@@ -263,6 +263,9 @@ WebInspector.TracingModel.Event = function(payload, level, thread) ...@@ -263,6 +263,9 @@ WebInspector.TracingModel.Event = function(payload, level, thread)
this.phase = payload.ph; this.phase = payload.ph;
this.level = level; this.level = level;
if (payload.dur)
this._setEndTime((payload.ts + payload.dur) / 1000);
if (payload.id) if (payload.id)
this.id = payload.id; this.id = payload.id;
...@@ -287,12 +290,16 @@ WebInspector.TracingModel.Event = function(payload, level, thread) ...@@ -287,12 +290,16 @@ WebInspector.TracingModel.Event = function(payload, level, thread)
WebInspector.TracingModel.Event.prototype = { WebInspector.TracingModel.Event.prototype = {
/** /**
* @param {number} duration * @param {number} endTime
*/ */
_setDuration: function(duration) _setEndTime: function(endTime)
{ {
this.endTime = this.startTime + duration; if (endTime < this.startTime) {
this.duration = duration; console.assert(false, "Event out of order: " + this.name);
return;
}
this.endTime = endTime;
this.duration = endTime - this.startTime;
}, },
/** /**
...@@ -311,12 +318,7 @@ WebInspector.TracingModel.Event.prototype = { ...@@ -311,12 +318,7 @@ WebInspector.TracingModel.Event.prototype = {
this.args[name] = payload.args[name]; this.args[name] = payload.args[name];
} }
} }
var duration = payload.ts / 1000 - this.startTime; this._setEndTime(payload.ts / 1000);
if (duration < 0) {
console.assert(false, "Event out of order: " + this.name);
return;
}
this._setDuration(duration);
} }
} }
...@@ -472,7 +474,7 @@ WebInspector.TracingModel.Thread.prototype = { ...@@ -472,7 +474,7 @@ WebInspector.TracingModel.Thread.prototype = {
*/ */
addEvent: function(payload) addEvent: function(payload)
{ {
for (var top = this._stack.peekLast(); top && top.endTime && top.endTime <= payload.ts;) { for (var top = this._stack.peekLast(); top && top.endTime && top.endTime <= payload.ts / 1000;) {
this._stack.pop(); this._stack.pop();
top = this._stack.peekLast(); top = this._stack.peekLast();
} }
...@@ -486,8 +488,6 @@ WebInspector.TracingModel.Thread.prototype = { ...@@ -486,8 +488,6 @@ WebInspector.TracingModel.Thread.prototype = {
var event = new WebInspector.TracingModel.Event(payload, this._stack.length, this); var event = new WebInspector.TracingModel.Event(payload, this._stack.length, this);
if (payload.ph === WebInspector.TracingModel.Phase.Begin || payload.ph === WebInspector.TracingModel.Phase.Complete) { if (payload.ph === WebInspector.TracingModel.Phase.Begin || payload.ph === WebInspector.TracingModel.Phase.Complete) {
if (payload.ph === WebInspector.TracingModel.Phase.Complete)
event._setDuration(payload.dur / 1000);
this._stack.push(event); this._stack.push(event);
if (this._maxStackDepth < this._stack.length) if (this._maxStackDepth < this._stack.length)
this._maxStackDepth = this._stack.length; this._maxStackDepth = this._stack.length;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment