Skip to content

Commit bf976ba

Browse files
committed
Update dumpsys output
After using the new format for a few days, I decided it's better to ahve the auth & acct info on every row because we will sometimes grep the data and won't see it if the auth/acct is ommited. Also added the "time since last sync" to every row. This is also very useful. Detailed Statistics (Recent history): 31 (# of times) 119s (sync time) ------------------------------------------------------------------------------------- subscribedfeeds : 8/25% 17s/14% aagmtest2@gmail.com/com.google : 5/16% 16s/13% aagmtest1@gmail.com/com.google : 3/9% 1s/0% ------------------------------------------------------------------------------------- com.android.calendar : 5/16% 10s/8% aagmtest2@gmail.com/com.google : 3/9% 0s/0% aagmtest1@gmail.com/com.google : 2/6% 9s/8% ------------------------------------------------------------------------------------- com.google.android.apps.books : 3/9% 26s/22% ------------------------------------------------------------------------------------- com.android.contacts : 3/9% 14s/11% aagmtest1@gmail.com/com.google : 2/6% 9s/7% aagmtest2@gmail.com/com.google : 1/3% 5s/4% ------------------------------------------------------------------------------------- com.android.browser : 3/9% 12s/10% ------------------------------------------------------------------------------------- com.google.android.music.MusicContent : 3/9% 7s/6% ------------------------------------------------------------------------------------- gmail-ls : 2/6% 12s/10% ------------------------------------------------------------------------------------- com.google.android.apps.plus.content.EsGooglePhotoProvider : 2/6% 1s/0% aagmtest2@gmail.com/com.google : 1/3% 1s/0% aagmtest1@gmail.com/com.google : 1/3% 0s/0% ------------------------------------------------------------------------------------- com.google.android.apps.plus.content.EsProvider : 1/3% 10s/9% ------------------------------------------------------------------------------------- com.google.android.gallery3d.GooglePhotoProvider : 1/3% 5s/5% ------------------------------------------------------------------------------------- Recent Sync History #1 : 2011-10-03 13:26:41 SERVER 0.0s aagmtest2@gmail.com/com.google com.android.calendar #2 : 2011-10-03 13:26:40 LOCAL 1.8s aagmtest2@gmail.com/com.google subscribedfeeds zsol#3 : 2011-10-03 13:26:40 LOCAL 0.1s aagmtest1@gmail.com/com.google subscribedfeeds #4 : 2011-10-03 13:26:37 SERVER 0.1s 4 aagmtest2@gmail.com/com.google com.android.calendar #5 : 2011-10-03 13:26:37 LOCAL 0.1s aagmtest2@gmail.com/com.google com.google.android.apps.books #6 : 2011-10-03 13:26:30 SERVER 0.9s 7 aagmtest2@gmail.com/com.google com.google.android.apps.books #7 : 2011-10-03 13:26:25 SERVER 1.1s aagmtest2@gmail.com/com.google gmail-ls #8 : 2011-10-03 13:26:13 SERVER 11.8s 11 aagmtest2@gmail.com/com.google gmail-ls #9 : 2011-10-03 13:26:08 SERVER 5.0s aagmtest2@gmail.com/com.google com.android.contacts #10 : 2011-10-03 13:26:08 SERVER 0.7s 29 aagmtest2@gmail.com/com.google com.android.calendar #11 : 2011-10-03 13:26:07 SERVER 0.7s aagmtest2@gmail.com/com.google com.android.browser #12 : 2011-10-03 13:26:04 SERVER 3.0s 2 aagmtest2@gmail.com/com.google com.android.browser #13 : 2011-10-03 13:26:04 SERVER 25.9s 25 aagmtest2@gmail.com/com.google com.google.android.apps.books Change-Id: I8da004f469d136fd9a86310b262eba61197fd0e7
1 parent 8ebf1ef commit bf976ba

File tree

1 file changed

+48
-40
lines changed

1 file changed

+48
-40
lines changed

core/java/android/content/SyncManager.java

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,50 +1301,47 @@ public int compare(AuthoritySyncStats lhs, AuthoritySyncStats rhs) {
13011301

13021302
elapsedTime = authoritySyncStats.elapsedTime;
13031303
times = authoritySyncStats.times;
1304-
timeStr = String.format("%d/%d%%",
1304+
timeStr = String.format("%ds/%d%%",
13051305
elapsedTime / 1000,
13061306
elapsedTime * 100 / totalElapsedTime);
13071307
timesStr = String.format("%d/%d%%",
13081308
times,
13091309
times * 100 / totalTimes);
13101310
pw.printf(authorityFormat, name, timesStr, timeStr);
13111311

1312-
if (authoritySyncStats.accountMap.size() > 1) {
1313-
final List<AccountSyncStats> sortedAccounts =
1314-
new ArrayList<AccountSyncStats>(
1315-
authoritySyncStats.accountMap.values());
1316-
Collections.sort(sortedAccounts, new Comparator<AccountSyncStats>() {
1317-
@Override
1318-
public int compare(AccountSyncStats lhs, AccountSyncStats rhs) {
1319-
// reverse order
1320-
int compare = Integer.compare(rhs.times, lhs.times);
1321-
if (compare == 0) {
1322-
compare = Long.compare(rhs.elapsedTime, lhs.elapsedTime);
1323-
}
1324-
return compare;
1312+
final List<AccountSyncStats> sortedAccounts =
1313+
new ArrayList<AccountSyncStats>(
1314+
authoritySyncStats.accountMap.values());
1315+
Collections.sort(sortedAccounts, new Comparator<AccountSyncStats>() {
1316+
@Override
1317+
public int compare(AccountSyncStats lhs, AccountSyncStats rhs) {
1318+
// reverse order
1319+
int compare = Integer.compare(rhs.times, lhs.times);
1320+
if (compare == 0) {
1321+
compare = Long.compare(rhs.elapsedTime, lhs.elapsedTime);
13251322
}
1326-
});
1327-
for (AccountSyncStats stats: sortedAccounts) {
1328-
elapsedTime = stats.elapsedTime;
1329-
times = stats.times;
1330-
timeStr = String.format("%d/%d%%",
1331-
elapsedTime / 1000,
1332-
elapsedTime * 100 / totalElapsedTime);
1333-
timesStr = String.format("%d/%d%%",
1334-
times,
1335-
times * 100 / totalTimes);
1336-
pw.printf(accountFormat, stats.name, timesStr, timeStr);
1323+
return compare;
13371324
}
1325+
});
1326+
for (AccountSyncStats stats: sortedAccounts) {
1327+
elapsedTime = stats.elapsedTime;
1328+
times = stats.times;
1329+
timeStr = String.format("%ds/%d%%",
1330+
elapsedTime / 1000,
1331+
elapsedTime * 100 / totalElapsedTime);
1332+
timesStr = String.format("%d/%d%%",
1333+
times,
1334+
times * 100 / totalTimes);
1335+
pw.printf(accountFormat, stats.name, timesStr, timeStr);
13381336
}
13391337
pw.println(separator);
13401338
}
13411339

13421340
pw.println();
13431341
pw.println("Recent Sync History");
13441342
final String format = " %-" + maxAccount + "s %s\n";
1345-
String lastAuthorityName = null;
1346-
String lastAccountKey = null;
1347-
long lastEventTime = 0;
1343+
final Map<String, Long> lastTimeMap = Maps.newHashMap();
1344+
13481345
for (int i = 0; i < N; i++) {
13491346
SyncStorageEngine.SyncHistoryItem item = items.get(i);
13501347
SyncStorageEngine.AuthorityInfo authority
@@ -1363,21 +1360,32 @@ public int compare(AccountSyncStats lhs, AccountSyncStats rhs) {
13631360
final long eventTime = item.eventTime;
13641361
time.set(eventTime);
13651362

1366-
pw.printf(" #%-3d: %s %8s %5.1fs",
1367-
i + 1,
1368-
formatTime(eventTime),
1369-
SyncStorageEngine.SOURCES[item.source],
1370-
((float) elapsedTime) / 1000);
1371-
if (authorityName.equals(lastAuthorityName) && accountKey.equals(lastAccountKey)) {
1372-
final long span = (lastEventTime - eventTime) / 1000;
1373-
pw.printf(" %02d:%02d\n", span / 60, span % 60);
1363+
final String key = authorityName + "/" + accountKey;
1364+
final Long lastEventTime = lastTimeMap.get(key);
1365+
final String diffString;
1366+
if (lastEventTime == null) {
1367+
diffString = "";
13741368
} else {
1375-
pw.printf(format, accountKey, authorityName);
1369+
final long diff = (lastEventTime - eventTime) / 1000;
1370+
if (diff < 60) {
1371+
diffString = String.valueOf(diff);
1372+
} else if (diff < 3600) {
1373+
diffString = String.format("%02d:%02d", diff / 60, diff % 60);
1374+
} else {
1375+
final long sec = diff % 3600;
1376+
diffString = String.format("%02d:%02d:%02d",
1377+
diff / 3600, sec / 60, sec % 60);
1378+
}
13761379
}
1380+
lastTimeMap.put(key, eventTime);
13771381

1378-
lastAuthorityName = authorityName;
1379-
lastAccountKey = accountKey;
1380-
lastEventTime = eventTime;
1382+
pw.printf(" #%-3d: %s %8s %5.1fs %8s",
1383+
i + 1,
1384+
formatTime(eventTime),
1385+
SyncStorageEngine.SOURCES[item.source],
1386+
((float) elapsedTime) / 1000,
1387+
diffString);
1388+
pw.printf(format, accountKey, authorityName);
13811389

13821390
if (item.event != SyncStorageEngine.EVENT_STOP
13831391
|| item.upstreamActivity != 0

0 commit comments

Comments
 (0)