зеркало из https://github.com/mozilla/pjs.git
Bug 717105 followup: substract process lifetime from timeStamps so that the values are actually useful, r=taras
This commit is contained in:
Родитель
a6bc13fdfa
Коммит
17edf8c520
|
@ -14,18 +14,20 @@ function test() {
|
|||
Cu.import("resource:///modules/TelemetryTimestamps.jsm");
|
||||
let now = Date.now();
|
||||
TelemetryTimestamps.add("foo");
|
||||
let fooValue = TelemetryTimestamps.get().foo;
|
||||
ok(fooValue, "foo was added");
|
||||
ok(fooValue >= now, "foo has a reasonable value");
|
||||
ok(TelemetryTimestamps.get().foo, "foo was added");
|
||||
ok(TelemetryTimestamps.get().foo >= now, "foo has a reasonable value");
|
||||
|
||||
// Add timestamp with value
|
||||
TelemetryTimestamps.add("bar", 1);
|
||||
// Use a value far in the future since TelemetryPing substracts the time of
|
||||
// process initialization.
|
||||
const YEAR_4000_IN_MS = 64060588800000;
|
||||
TelemetryTimestamps.add("bar", YEAR_4000_IN_MS);
|
||||
ok(TelemetryTimestamps.get().bar, "bar was added");
|
||||
is(TelemetryTimestamps.get().bar, 1, "bar has the right value");
|
||||
is(TelemetryTimestamps.get().bar, YEAR_4000_IN_MS, "bar has the right value");
|
||||
|
||||
// Can't add the same timestamp twice
|
||||
TelemetryTimestamps.add("bar", 2);
|
||||
is(TelemetryTimestamps.get().bar, 1, "bar wasn't overwritten");
|
||||
is(TelemetryTimestamps.get().bar, YEAR_4000_IN_MS, "bar wasn't overwritten");
|
||||
|
||||
let threw = false;
|
||||
try {
|
||||
|
@ -39,8 +41,8 @@ function test() {
|
|||
// Test that the data gets added to the telemetry ping properly
|
||||
let simpleMeasurements = getSimpleMeasurementsFromTelemetryPing();
|
||||
ok(simpleMeasurements, "got simple measurements from ping data");
|
||||
is(simpleMeasurements.foo, fooValue, "foo was included");
|
||||
is(simpleMeasurements.bar, 1, "bar was included");
|
||||
ok(simpleMeasurements.foo > 1, "foo was included");
|
||||
ok(simpleMeasurements.bar > 1, "bar was included");
|
||||
ok(!simpleMeasurements.baz, "baz wasn't included since it wasn't added");
|
||||
|
||||
// Check browser timestamps that we add
|
||||
|
@ -57,6 +59,6 @@ function test() {
|
|||
let value = simpleMeasurements[p];
|
||||
ok(value, p + " exists");
|
||||
ok(!isNaN(value), p + " is a number");
|
||||
ok(value > 0 && value < Date.now(), p + " value is reasonable");
|
||||
ok(value > 0, p + " value is reasonable");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -108,19 +108,6 @@ function getSimpleMeasurements() {
|
|||
uptime: Math.round((new Date() - si.process) / 60000)
|
||||
}
|
||||
|
||||
if (si.process) {
|
||||
for each (let field in ["main", "firstPaint", "sessionRestored"]) {
|
||||
if (!(field in si))
|
||||
continue;
|
||||
ret[field] = si[field] - si.process
|
||||
}
|
||||
}
|
||||
ret.startupInterrupted = new Number(Services.startup.interrupted);
|
||||
|
||||
ret.js = Cc["@mozilla.org/js/xpc/XPConnect;1"]
|
||||
.getService(Ci.nsIJSEngineTelemetryStats)
|
||||
.telemetryValue;
|
||||
|
||||
// Look for app-specific timestamps
|
||||
var appTimestamps = {};
|
||||
try {
|
||||
|
@ -129,11 +116,25 @@ function getSimpleMeasurements() {
|
|||
appTimestamps = o.TelemetryTimestamps.get();
|
||||
} catch (ex) {}
|
||||
|
||||
for (let p in appTimestamps) {
|
||||
if (!(p in ret) && appTimestamps[p])
|
||||
ret[p] = appTimestamps[p];
|
||||
if (si.process) {
|
||||
for each (let field in ["main", "firstPaint", "sessionRestored"]) {
|
||||
if (!(field in si))
|
||||
continue;
|
||||
ret[field] = si[field] - si.process
|
||||
}
|
||||
|
||||
for (let p in appTimestamps) {
|
||||
if (!(p in ret) && appTimestamps[p])
|
||||
ret[p] = appTimestamps[p] - si.process;
|
||||
}
|
||||
}
|
||||
|
||||
ret.startupInterrupted = new Number(Services.startup.interrupted);
|
||||
|
||||
ret.js = Cc["@mozilla.org/js/xpc/XPConnect;1"]
|
||||
.getService(Ci.nsIJSEngineTelemetryStats)
|
||||
.telemetryValue;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче