Bug 741042 - Add telemetry support for timing XUL profile import. r=blassey

This commit is contained in:
Gian-Carlo Pascutto 2012-04-12 23:19:57 +02:00
Родитель 6db37a3fe6
Коммит 4f868238f3
2 изменённых файлов: 36 добавлений и 1 удалений

Просмотреть файл

@ -156,6 +156,12 @@ public class ProfileMigrator {
private static final int kPlacesTypeBookmark = 1;
private static final int kPlacesTypeFolder = 2;
/*
For statistics keeping.
*/
private final String kHistoryCountQuery =
"SELECT COUNT(*) FROM moz_historyvisits";
/*
The sort criterion here corresponds to the one used for the
Awesomebar results. It's a simplification of Frecency.
@ -200,7 +206,16 @@ public class ProfileMigrator {
}
public void launch() {
boolean timeThisRun = false;
Telemetry.Timer timer = null;
// First run, time things
if (!hasMigrationRun()) {
timeThisRun = true;
timer = new Telemetry.Timer("BROWSERPROVIDER_XUL_IMPORT_TIME");
}
launch(DEFAULT_HISTORY_MIGRATE_COUNT);
if (timeThisRun)
timer.stop();
}
public void launch(int maxEntries) {
@ -481,6 +496,12 @@ public class ProfileMigrator {
int queryResultEntries = 0;
try {
Cursor cursor = db.rawQuery(kHistoryCountQuery, null);
cursor.moveToFirst();
int historyCount = cursor.getInt(0);
Telemetry.HistogramAdd("BROWSERPROVIDER_XUL_IMPORT_HISTORY",
historyCount);
final String currentTime = Long.toString(System.currentTimeMillis());
final String[] queryParams = new String[] {
/* current time */
@ -489,7 +510,7 @@ public class ProfileMigrator {
Integer.toString(maxEntries),
Integer.toString(currentEntries)
};
Cursor cursor = db.rawQuery(kHistoryQuery, queryParams);
cursor = db.rawQuery(kHistoryQuery, queryParams);
queryResultEntries = cursor.getCount();
final int urlCol = cursor.getColumnIndex(kHistoryUrl);
@ -657,6 +678,11 @@ public class ProfileMigrator {
final int faviconUrlCol = cursor.getColumnIndex(kFaviconUrl);
final int faviconGuidCol = cursor.getColumnIndex(kFaviconGuid);
// Keep statistics
int bookmarkCount = cursor.getCount();
Telemetry.HistogramAdd("BROWSERPROVIDER_XUL_IMPORT_BOOKMARKS",
bookmarkCount);
// The keys are places IDs.
Set<Long> openFolders = new HashSet<Long>();
Set<Long> knownFolders = new HashSet<Long>(mRerootMap.keySet());

Просмотреть файл

@ -434,6 +434,15 @@ HISTOGRAM_FLAG(TELEMETRY_TEST_FLAG, "a testing histogram; not meant to be touche
HISTOGRAM_FLAG(STARTUP_CRASH_DETECTED, "Whether there was a crash during the last startup")
HISTOGRAM_ENUMERATED_VALUES(SAFE_MODE_USAGE, 3, "Whether the user is in safe mode (No, Yes, Forced)")
/**
* Native Fennec Telemetry
*/
#if defined(ANDROID)
HISTOGRAM(BROWSERPROVIDER_XUL_IMPORT_TIME, 20, 600000, 20, EXPONENTIAL, "Time for the initial conversion of a XUL places database (ms)")
HISTOGRAM(BROWSERPROVIDER_XUL_IMPORT_BOOKMARKS, 1, 50000, 20, EXPONENTIAL, "Time for the initial conversion of a XUL places database (ms)")
HISTOGRAM(BROWSERPROVIDER_XUL_IMPORT_HISTORY, 1, 1000000, 20, EXPONENTIAL, "Time for the initial conversion of a XUL places database (ms)")
#endif
#undef HISTOGRAM_ENUMERATED_VALUES
#undef HISTOGRAM_BOOLEAN
#undef HISTOGRAM_FLAG