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

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: Infinity/NaN in scalar.py -- this is why there should be only one implementation of Values 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
Index: tracing/tracing/value/numeric.html
diff --git a/tracing/tracing/value/numeric.html b/tracing/tracing/value/numeric.html
index 5f72264fa8fc254dd2a652abd773b2dbeb7563d8..4633433947146ed037a8be418d4c937cee088e3f 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,17 @@ 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;
+ if (d.value === 'Infinity')
+ d.value = Infinity;
+ if (value === 'NaN')
+ d.value = NaN;
+ }
+
return new ScalarNumeric(tr.v.Unit.fromJSON(d.unit), d.value);
};
« telemetry/telemetry/value/scalar.py ('K') | « 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