Bug 1063561 - Convert Addon Manager telemetry timings to use Components.utils.now(); r=irvingreid
authorManu Jain <manu.jain13@gmail.com>
Fri, 19 Sep 2014 14:04:49 -0400
changeset 206254 92d6f9e6cbc397bc5130b094a89605d0a5584866
parent 206253 1a986002b2648cb9b540064c4cf8fe18656c5bbb
child 206255 2192dc45e484b1ba551396a640393d66506b1cfa
push id27519
push userkwierso@gmail.com
push dateFri, 19 Sep 2014 23:56:39 +0000
treeherdermozilla-central@a85324dfc960 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersirvingreid
bugs1063561
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1063561 - Convert Addon Manager telemetry timings to use Components.utils.now(); r=irvingreid
toolkit/mozapps/extensions/AddonManager.jsm
toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -2426,19 +2426,19 @@ this.AddonManagerPrivate = {
 
   setTelemetryDetails: function AMP_setTelemetryDetails(aProvider, aDetails) {
     AddonManagerInternal.telemetryDetails[aProvider] = aDetails;
   },
 
   // Start a timer, record a simple measure of the time interval when
   // timer.done() is called
   simpleTimer: function(aName) {
-    let startTime = Date.now();
+    let startTime = Cu.now();
     return {
-      done: () => this.recordSimpleMeasure(aName, Date.now() - startTime)
+      done: () => this.recordSimpleMeasure(aName, Math.round(Cu.now() - startTime))
     };
   },
 
   /**
    * Helper to call update listeners when no update is available.
    *
    * This can be used as an implementation for Addon.findUpdates() when
    * no update mechanism is available.
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -1489,17 +1489,17 @@ XPIState.prototype = {
   /**
    * Update the last modified time for an add-on on disk.
    * @param aFile: nsIFile path of the add-on.
    * @param aId: The add-on ID.
    * @return True if the time stamp has changed.
    */
   getModTime(aFile, aId) {
     let changed = false;
-    let scanStarted = Date.now();
+    let scanStarted = Cu.now();
     // For an unknown or enabled add-on, we do a full recursive scan.
     if (!('scanTime' in this) || this.enabled) {
       logger.debug('getModTime: Recursive scan of ' + aId);
       let [modFile, modTime, items] = recursiveLastModifiedTime(aFile);
       XPIProvider._mostRecentlyModifiedFile[aId] = modFile;
       XPIProvider.setTelemetry(aId, "scan_items", items);
       if (modTime != this.scanTime) {
         this.scanTime = modTime;
@@ -1534,17 +1534,17 @@ XPIState.prototype = {
         }
       } catch (e) {
         logger.warn("Can't get modified time of ${file}: ${e}", {file: aFile.path, e: e});
         changed = true;
         this.scanTime = 0;
       }
     }
     // Record duration of file-modified check
-    XPIProvider.setTelemetry(aId, "scan_MS", Date.now() - scanStarted);
+    XPIProvider.setTelemetry(aId, "scan_MS", Math.round(Cu.now() - scanStarted));
 
     return changed;
   },
 
   /**
    * Update the XPIState to match an XPIDatabase entry; if 'enabled' is changed to true,
    * update the last-modified time. This should probably be made async, but for now we
    * don't want to maintain parallel sync and async versions of the scan.
@@ -3534,20 +3534,20 @@ this.XPIProvider = {
     {
       updated = this.installDistributionAddons(manifests);
       if (updated) {
         updateReasons.push("installDistributionAddons");
       }
     }
 
     // Telemetry probe added around getInstallState() to check perf
-    let telemetryCaptureTime = Date.now();
+    let telemetryCaptureTime = Cu.now();
     let installChanged = XPIStates.getInstallState();
     let telemetry = Services.telemetry;
-    telemetry.getHistogramById("CHECK_ADDONS_MODIFIED_MS").add(Date.now() - telemetryCaptureTime);
+    telemetry.getHistogramById("CHECK_ADDONS_MODIFIED_MS").add(Math.round(Cu.now() - telemetryCaptureTime));
     if (installChanged) {
       updateReasons.push("directoryState");
     }
 
     let haveAnyAddons = (XPIStates.size > 0);
 
     // If the schema appears to have changed then we should update the database
     if (DB_SCHEMA != Preferences.get(PREF_DB_SCHEMA, 0)) {