Skip to content

Commit

Permalink
Merge pull request google#113 from google/precisetimes
Browse files Browse the repository at this point in the history
Show event times that are <1ms in the filter bar.
  • Loading branch information
benvanik committed Dec 12, 2012
2 parents 6b4c3a9 + 89ee537 commit 17a8de4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/wtf/app/ui/nav/framebar.soy
Expand Up @@ -21,6 +21,7 @@
<div class="{css wtfAppUiFramebar}">
<div class="{css wtfAppUiFramebarOuter}">
<canvas class="{css wtfAppUiFramebarCanvas}" width="1" height="1"></canvas>
<div class="{css kScrollShadowBottom}"></div>
</div>
<div class="{css wtfAppUiFramebarInfoOuter}">
<div class="{css kSrollBarInner} {css wtfAppUiFramebarInfo}">
Expand Down
2 changes: 0 additions & 2 deletions src/wtf/app/ui/nav/navbar.soy
Expand Up @@ -22,7 +22,5 @@
<div class="{css wtfAppUiNavbarTimeline}"></div>
<div class="{css wtfAppUiNavbarFramebar}"></div>
<div class="{css wtfAppUiNavbarSplitter}"></div>
<div class="{css kScrollShadowTop}"></div>
<div class="{css kScrollShadowBottom}"></div>
</div>
{/template}
25 changes: 4 additions & 21 deletions src/wtf/app/ui/tracks/trackinfobar.js
Expand Up @@ -28,6 +28,7 @@ goog.require('wtf.events.EventType');
goog.require('wtf.events.KeyboardScope');
goog.require('wtf.ui.Control');
goog.require('wtf.ui.SearchControl');
goog.require('wtf.util');



Expand Down Expand Up @@ -205,27 +206,9 @@ wtf.app.ui.tracks.TrackInfoBar.prototype.buildTableRow_ = function(

var content = '';
if (entry instanceof wtf.analysis.db.ScopeEventDataEntry) {
var totalTime = Math.round(entry.getTotalTime());
if (!totalTime) {
totalTime = '0';
} else if (totalTime < 1) {
totalTime = '<1';
}
totalTime += 'ms';
var userTime = Math.round(entry.getUserTime());
if (!userTime) {
userTime = '0';
} else if (userTime < 1) {
userTime = '<1';
}
userTime += 'ms';
var meanTime = Math.round(entry.getMeanTime());
if (!meanTime) {
meanTime = '0';
} else if (meanTime < 1) {
meanTime = '<1';
}
meanTime += 'ms';
var totalTime = wtf.util.formatSmallTime(entry.getTotalTime());
var userTime = wtf.util.formatSmallTime(entry.getUserTime());
var meanTime = wtf.util.formatSmallTime(entry.getMeanTime());
content +=
entry.getCount() + ', ' +
totalTime + ' t, ' +
Expand Down
19 changes: 18 additions & 1 deletion src/wtf/util/util.js
Expand Up @@ -20,7 +20,7 @@ goog.require('goog.string');


/**
* Formats a time value, maintaining all precision.
* Formats a time value, rounding to ms at 3 decimal places.
* @param {number} value Time value.
* @return {string} Formatted time string.
*/
Expand All @@ -29,6 +29,23 @@ wtf.util.formatTime = function(value) {
};


/**
* Formats a time value, rounding to ms and to ms at 3 decimal places if <1.
* @param {number} value Time value.
* @return {string} Formatted time string, plus units.
*/
wtf.util.formatSmallTime = function(value) {
if (value == 0) {
return '0ms';
} else if (value < 1) {
return value.toFixed(3) + 'ms';
} else if (value < 10) {
return value.toFixed(2) + 'ms';
}
return value.toFixed(0) + 'ms';
};


/**
* Formats time in the standard format.
* @param {number} value Wall-time.
Expand Down

0 comments on commit 17a8de4

Please sign in to comment.