Skip to content

Commit e8fd81f

Browse files
committed
Fix DFL-3385: NaN values emitted to console after profiling.
1 parent f13182e commit e8fd81f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/profiler/profiler_templates.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ var ProfilerTemplates = function()
8484
var style_sheets = document.styleSheets;
8585
var profiler_event_decl = style_sheets.getDeclaration(".profiler-event");
8686
var profiler_timeline_row_decl = style_sheets.getDeclaration(".profiler-timeline-row");
87+
var profiler_event_tooltip_decl = style_sheets.getDeclaration(".profiler-event-tooltip");
8788
var BAR_MIN_WIDTH = profiler_event_decl ? parseInt(profiler_event_decl.minWidth) : 0;
8889
var BAR_HEIGHT = profiler_timeline_row_decl
89-
? (parseInt(style_sheets.getDeclaration(".profiler-timeline-row").height) +
90-
parseInt(style_sheets.getDeclaration(".profiler-timeline-row").paddingTop) +
91-
parseInt(style_sheets.getDeclaration(".profiler-timeline-row").paddingBottom))
90+
? (parseInt(profiler_timeline_row_decl.height) +
91+
parseInt(profiler_timeline_row_decl.paddingTop) +
92+
parseInt(profiler_timeline_row_decl.paddingBottom))
9293
: 0;
94+
var TOOLTIP_WIDTH = profiler_event_tooltip_decl
95+
? parseInt(profiler_event_tooltip_decl.width)
96+
: 0;
9397

9498
this._order = [
9599
EVENT_TYPE_DOCUMENT_PARSING,
@@ -240,7 +244,7 @@ var ProfilerTemplates = function()
240244
this._timeline_event = function(interval_start, ms_unit, selected_id, event)
241245
{
242246
var interval = Math.round((event.interval.end - event.interval.start) * ms_unit);
243-
var self_time = Math.max(BAR_MIN_WIDTH, Math.round(event.time * ms_unit));
247+
var self_time = interval ? Math.max(BAR_MIN_WIDTH, Math.round(event.time * ms_unit)) : 0;
244248
var event_start = Math.round((event.interval.start - interval_start) * ms_unit);
245249
var column = this._order.indexOf(event.type);
246250
var is_expandable = this._expandables.indexOf(event.type) != -1 && event.childCount > 1;
@@ -463,15 +467,14 @@ var ProfilerTemplates = function()
463467

464468
this.get_title_interval_bar = function(event)
465469
{
466-
var WIDTH = 200;
467470
var interval = event.interval.end - event.interval.start;
468-
var ms_unit = WIDTH / interval;
471+
var ms_unit = interval ? (TOOLTIP_WIDTH / interval) : 0;
469472
var self_time = Math.round(event.time * ms_unit);
470473
var color = this._event_colors[event.type] || (this._event_colors[event.type] = this._get_color_for_type(event.type));
471474
return (
472475
["div",
473476
"style",
474-
"width: " + WIDTH + "px; " +
477+
"width: " + TOOLTIP_WIDTH + "px; " +
475478
"background-image: -o-linear-gradient(90deg, transparent 0, rgba(255,255,255,.25) 100%), " +
476479
"-o-linear-gradient(0, " + color + " 0, " +
477480
color + " " + self_time + "px, " +

0 commit comments

Comments
 (0)