Skip to content

Commit

Permalink
Update dumpsys output
Browse files Browse the repository at this point in the history
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%
    [email protected]/com.google                            :   5/16%      16s/13%
    [email protected]/com.google                            :   3/9%       1s/0%
-------------------------------------------------------------------------------------
  com.android.calendar                                        : 5/16%      10s/8%
    [email protected]/com.google                            :   3/9%       0s/0%
    [email protected]/com.google                            :   2/6%       9s/8%
-------------------------------------------------------------------------------------
  com.google.android.apps.books                               : 3/9%       26s/22%
-------------------------------------------------------------------------------------
  com.android.contacts                                        : 3/9%       14s/11%
    [email protected]/com.google                            :   2/6%       9s/7%
    [email protected]/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%
    [email protected]/com.google                            :   1/3%       1s/0%
    [email protected]/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            [email protected]/com.google  com.android.calendar
  #2  : 2011-10-03 13:26:40    LOCAL    1.8s            [email protected]/com.google  subscribedfeeds
  zsol#3  : 2011-10-03 13:26:40    LOCAL    0.1s            [email protected]/com.google  subscribedfeeds
  #4  : 2011-10-03 13:26:37   SERVER    0.1s         4  [email protected]/com.google  com.android.calendar
  #5  : 2011-10-03 13:26:37    LOCAL    0.1s            [email protected]/com.google  com.google.android.apps.books
  #6  : 2011-10-03 13:26:30   SERVER    0.9s         7  [email protected]/com.google  com.google.android.apps.books
  #7  : 2011-10-03 13:26:25   SERVER    1.1s            [email protected]/com.google  gmail-ls
  #8  : 2011-10-03 13:26:13   SERVER   11.8s        11  [email protected]/com.google  gmail-ls
  #9  : 2011-10-03 13:26:08   SERVER    5.0s            [email protected]/com.google  com.android.contacts
  #10 : 2011-10-03 13:26:08   SERVER    0.7s        29  [email protected]/com.google  com.android.calendar
  #11 : 2011-10-03 13:26:07   SERVER    0.7s            [email protected]/com.google  com.android.browser
  #12 : 2011-10-03 13:26:04   SERVER    3.0s         2  [email protected]/com.google  com.android.browser
  #13 : 2011-10-03 13:26:04   SERVER   25.9s        25  [email protected]/com.google  com.google.android.apps.books

Change-Id: I8da004f469d136fd9a86310b262eba61197fd0e7
  • Loading branch information
alonalbert committed Oct 3, 2011
1 parent 8ebf1ef commit bf976ba
Showing 1 changed file with 48 additions and 40 deletions.
88 changes: 48 additions & 40 deletions core/java/android/content/SyncManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1301,50 +1301,47 @@ public int compare(AuthoritySyncStats lhs, AuthoritySyncStats rhs) {

elapsedTime = authoritySyncStats.elapsedTime;
times = authoritySyncStats.times;
timeStr = String.format("%d/%d%%",
timeStr = String.format("%ds/%d%%",
elapsedTime / 1000,
elapsedTime * 100 / totalElapsedTime);
timesStr = String.format("%d/%d%%",
times,
times * 100 / totalTimes);
pw.printf(authorityFormat, name, timesStr, timeStr);

if (authoritySyncStats.accountMap.size() > 1) {
final List<AccountSyncStats> sortedAccounts =
new ArrayList<AccountSyncStats>(
authoritySyncStats.accountMap.values());
Collections.sort(sortedAccounts, new Comparator<AccountSyncStats>() {
@Override
public int compare(AccountSyncStats lhs, AccountSyncStats rhs) {
// reverse order
int compare = Integer.compare(rhs.times, lhs.times);
if (compare == 0) {
compare = Long.compare(rhs.elapsedTime, lhs.elapsedTime);
}
return compare;
final List<AccountSyncStats> sortedAccounts =
new ArrayList<AccountSyncStats>(
authoritySyncStats.accountMap.values());
Collections.sort(sortedAccounts, new Comparator<AccountSyncStats>() {
@Override
public int compare(AccountSyncStats lhs, AccountSyncStats rhs) {
// reverse order
int compare = Integer.compare(rhs.times, lhs.times);
if (compare == 0) {
compare = Long.compare(rhs.elapsedTime, lhs.elapsedTime);
}
});
for (AccountSyncStats stats: sortedAccounts) {
elapsedTime = stats.elapsedTime;
times = stats.times;
timeStr = String.format("%d/%d%%",
elapsedTime / 1000,
elapsedTime * 100 / totalElapsedTime);
timesStr = String.format("%d/%d%%",
times,
times * 100 / totalTimes);
pw.printf(accountFormat, stats.name, timesStr, timeStr);
return compare;
}
});
for (AccountSyncStats stats: sortedAccounts) {
elapsedTime = stats.elapsedTime;
times = stats.times;
timeStr = String.format("%ds/%d%%",
elapsedTime / 1000,
elapsedTime * 100 / totalElapsedTime);
timesStr = String.format("%d/%d%%",
times,
times * 100 / totalTimes);
pw.printf(accountFormat, stats.name, timesStr, timeStr);
}
pw.println(separator);
}

pw.println();
pw.println("Recent Sync History");
final String format = " %-" + maxAccount + "s %s\n";
String lastAuthorityName = null;
String lastAccountKey = null;
long lastEventTime = 0;
final Map<String, Long> lastTimeMap = Maps.newHashMap();

for (int i = 0; i < N; i++) {
SyncStorageEngine.SyncHistoryItem item = items.get(i);
SyncStorageEngine.AuthorityInfo authority
Expand All @@ -1363,21 +1360,32 @@ public int compare(AccountSyncStats lhs, AccountSyncStats rhs) {
final long eventTime = item.eventTime;
time.set(eventTime);

pw.printf(" #%-3d: %s %8s %5.1fs",
i + 1,
formatTime(eventTime),
SyncStorageEngine.SOURCES[item.source],
((float) elapsedTime) / 1000);
if (authorityName.equals(lastAuthorityName) && accountKey.equals(lastAccountKey)) {
final long span = (lastEventTime - eventTime) / 1000;
pw.printf(" %02d:%02d\n", span / 60, span % 60);
final String key = authorityName + "/" + accountKey;
final Long lastEventTime = lastTimeMap.get(key);
final String diffString;
if (lastEventTime == null) {
diffString = "";
} else {
pw.printf(format, accountKey, authorityName);
final long diff = (lastEventTime - eventTime) / 1000;
if (diff < 60) {
diffString = String.valueOf(diff);
} else if (diff < 3600) {
diffString = String.format("%02d:%02d", diff / 60, diff % 60);
} else {
final long sec = diff % 3600;
diffString = String.format("%02d:%02d:%02d",
diff / 3600, sec / 60, sec % 60);
}
}
lastTimeMap.put(key, eventTime);

lastAuthorityName = authorityName;
lastAccountKey = accountKey;
lastEventTime = eventTime;
pw.printf(" #%-3d: %s %8s %5.1fs %8s",
i + 1,
formatTime(eventTime),
SyncStorageEngine.SOURCES[item.source],
((float) elapsedTime) / 1000,
diffString);
pw.printf(format, accountKey, authorityName);

if (item.event != SyncStorageEngine.EVENT_STOP
|| item.upstreamActivity != 0
Expand Down

0 comments on commit bf976ba

Please sign in to comment.