Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: tracing/tracing/value/numeric.html

Issue 1964663003: [telemetry] Add Html2OutputFormatter for generating results2.html (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tracing/tracing/ui/value_set_view.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/value/numeric.html
diff --git a/tracing/tracing/value/numeric.html b/tracing/tracing/value/numeric.html
index 5f72264fa8fc254dd2a652abd773b2dbeb7563d8..f8fc53f890a6ecd424619850dbcc716a1a47cc0a 100644
--- a/tracing/tracing/value/numeric.html
+++ b/tracing/tracing/value/numeric.html
@@ -42,6 +42,9 @@ tr.exportTo('tr.v', function() {
if (d.type === 'scalar')
return ScalarNumeric.fromDict(d);
+ if (d.type === 'numeric')
+ return Numeric.fromDict(d);
+
throw new Error('Not implemented');
};
@@ -367,7 +370,7 @@ tr.exportTo('tr.v', function() {
tr.v.Unit.byName.unitlessNumber_smallerIsBetter : this.unit;
var key = statNameToKey(stat);
var statValue = this.running[key];
- if (statValue !== undefined) {
+ if (typeof(statValue) === 'number') {
results.push({
name: stat,
scalar: new tr.v.ScalarNumeric(statUnit, statValue)
@@ -619,7 +622,17 @@ tr.exportTo('tr.v', function() {
asDictInto_: function(d) {
d.type = 'scalar';
- d.value = this.value;
+
+ // Infinity and NaN are left out of JSON for security reasons that do not
+ // apply to our use cases.
+ if (this.value === Infinity)
+ d.value = 'Infinity';
+ else if (this.value === -Infinity)
+ d.value = '-Infinity';
+ else if (isNaN(this.value))
+ d.value = 'NaN';
+ else
+ d.value = this.value;
},
toString: function() {
@@ -628,6 +641,18 @@ tr.exportTo('tr.v', function() {
};
ScalarNumeric.fromDict = function(d) {
+ // Infinity and NaN are left out of JSON for security reasons that do not
+ // apply to our use cases.
+ if (typeof(d.value) === 'string') {
+ if (d.value === '-Infinity') {
+ d.value = -Infinity;
+ } else if (d.value === 'Infinity') {
+ d.value = Infinity;
+ } else if (d.value === 'NaN') {
+ d.value = NaN;
+ }
+ }
+
return new ScalarNumeric(tr.v.Unit.fromJSON(d.unit), d.value);
};
« no previous file with comments | « tracing/tracing/ui/value_set_view.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698