Bug 723924 - Telemetry for time needed for a single frecency update.
authorMarco Bonardo <mbonardo@mozilla.com>
Tue, 07 Feb 2012 16:01:07 +0100
changeset 86453 997e5fc795748cd7595263b9d1bd169c7821874b
parent 86452 7cdf565448694b50d226646e61b4654066aa03bf
child 86454 02e4c23ae67d78700f7a625598f84f3d297a72ac
child 86469 d2d46b209502c661f5a40b6df9a484abdf57ba52
push id94
push userbturner@mozilla.com
push dateWed, 08 Feb 2012 05:39:15 +0000
bugs723924
milestone13.0a1
Bug 723924 - Telemetry for time needed for a single frecency update. r=dietrich
toolkit/components/places/SQLFunctions.cpp
toolkit/components/places/tests/unit/test_telemetry.js
toolkit/components/telemetry/TelemetryHistograms.h
--- a/toolkit/components/places/SQLFunctions.cpp
+++ b/toolkit/components/places/SQLFunctions.cpp
@@ -46,16 +46,18 @@
 #include "nsMathUtils.h"
 #include "nsUTF8Utils.h"
 #include "nsINavHistoryService.h"
 #include "nsPrintfCString.h"
 #include "nsNavHistory.h"
 #if defined(XP_OS2)
 #include "nsIRandomGenerator.h"
 #endif
+#include "mozilla/Telemetry.h"
+
 using namespace mozilla::storage;
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Anonymous Helpers
 
 namespace {
 
   typedef nsACString::const_char_iterator const_char_iterator;
@@ -462,16 +464,18 @@ namespace places {
                                             nsIVariant **_result)
   {
     // Fetch arguments.  Use default values if they were omitted.
     PRUint32 numEntries;
     nsresult rv = aArguments->GetNumEntries(&numEntries);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ASSERTION(numEntries > 0, "unexpected number of arguments");
 
+    Telemetry::AutoTimer<Telemetry::PLACES_FRECENCY_CALC_TIME_MS> timer;
+
     PRInt64 pageId = aArguments->AsInt64(0);
     PRInt32 typed = numEntries > 1 ? aArguments->AsInt32(1) : 0;
     PRInt32 fullVisitCount = numEntries > 2 ? aArguments->AsInt32(2) : 0;
     PRInt64 bookmarkId = numEntries > 3 ? aArguments->AsInt64(3) : 0;
     PRInt32 visitCount = 0;
     PRInt32 hidden = 0;
     PRInt32 isQuery = 0;
     float pointsForSampledVisits = 0.0;
--- a/toolkit/components/places/tests/unit/test_telemetry.js
+++ b/toolkit/components/places/tests/unit/test_telemetry.js
@@ -21,16 +21,17 @@ let histograms = {
   PLACES_EXPIRATION_STEPS_TO_CLEAN: function (val) do_check_true(val > 1),
   //PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS:  function (val) do_check_true(val > 1),
   PLACES_IDLE_FRECENCY_DECAY_TIME_MS: function (val) do_check_true(val > 0),
   PLACES_IDLE_MAINTENANCE_TIME_MS: function (val) do_check_true(val > 0),
   PLACES_ANNOS_BOOKMARKS_COUNT: function (val) do_check_eq(val, 1),
   PLACES_ANNOS_BOOKMARKS_SIZE_KB: function (val) do_check_eq(val, 1),
   PLACES_ANNOS_PAGES_COUNT: function (val) do_check_eq(val, 1),
   PLACES_ANNOS_PAGES_SIZE_KB: function (val) do_check_eq(val, 1),
+  PLACES_FRECENCY_CALC_TIME_MS: function (val) do_check_true(val >= 0),
 }
 
 function run_test() {
   do_test_pending();
 
   // Put some trash in the database.
   const URI = NetUtil.newURI("http://moz.org/");
 
@@ -121,12 +122,14 @@ function continue_test() {
     check_telemetry();
   }, "places-maintenance-finished", false);
 }
 
 function check_telemetry() {
   for (let histogramId in histograms) {
     do_log_info("checking histogram " + histogramId);
     let validate = histograms[histogramId];
-    validate(Services.telemetry.getHistogramById(histogramId).snapshot().sum);
+    let snapshot = Services.telemetry.getHistogramById(histogramId).snapshot();
+    validate(snapshot.sum);
+    do_check_true(snapshot.counts.reduce(function(a, b) a + b) > 0);
   }
   do_test_finished();
 }
--- a/toolkit/components/telemetry/TelemetryHistograms.h
+++ b/toolkit/components/telemetry/TelemetryHistograms.h
@@ -288,16 +288,17 @@ HISTOGRAM(PLACES_DATABASE_SIZE_PER_PAGE_
 HISTOGRAM(PLACES_EXPIRATION_STEPS_TO_CLEAN, 1, 10, 10, LINEAR, "PLACES: Expiration steps to cleanup the database")
 HISTOGRAM(PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS, 50, 500, 10, EXPONENTIAL, "PLACES: Time for first autocomplete result if > 50ms (ms)")
 HISTOGRAM(PLACES_IDLE_FRECENCY_DECAY_TIME_MS, 50, 10000, 10, EXPONENTIAL, "PLACES: Time to decay all frecencies values on idle (ms)")
 HISTOGRAM(PLACES_IDLE_MAINTENANCE_TIME_MS, 1000, 30000, 10, EXPONENTIAL, "PLACES: Time to execute maintenance tasks on idle (ms)")
 HISTOGRAM(PLACES_ANNOS_BOOKMARKS_COUNT, 50, 5000, 10, EXPONENTIAL, "PLACES: Number of bookmarks annotations")
 HISTOGRAM(PLACES_ANNOS_BOOKMARKS_SIZE_KB, 10, 10000, 10, EXPONENTIAL, "PLACES: Size of bookmarks annotations (KB)")
 HISTOGRAM(PLACES_ANNOS_PAGES_COUNT, 50, 5000, 10, EXPONENTIAL, "PLACES: Number of pages annotations")
 HISTOGRAM(PLACES_ANNOS_PAGES_SIZE_KB, 10, 10000, 10, EXPONENTIAL, "PLACES: Size of pages annotations (KB)")
+HISTOGRAM(PLACES_FRECENCY_CALC_TIME_MS, 1, 100, 10, EXPONENTIAL, "PLACES: Time to calculate frecency of a page (ms)")
 
 /**
  * Updater telemetry.
  */
 HISTOGRAM(UPDATE_STATUS, 1, 16006, 27, LINEAR, "Updater: the status of the latest update performed")
 
 /**
  * Thunderbird-specific telemetry.