summaryrefslogtreecommitdiffstats
path: root/core/java/com/android
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-04-20 18:14:05 -0700
committerDianne Hackborn <hackbod@google.com>2009-04-22 18:03:21 -0700
commit1d442e0d990b581357f33f5463c7c5cb49b551e8 (patch)
tree58963b9ba095e179ba7c63e52dfd525b93cb978e /core/java/com/android
parenta0c9e8526b094e3b4f2c2747622059215d00516f (diff)
downloadframeworks_base-1d442e0d990b581357f33f5463c7c5cb49b551e8.zip
frameworks_base-1d442e0d990b581357f33f5463c7c5cb49b551e8.tar.gz
frameworks_base-1d442e0d990b581357f33f5463c7c5cb49b551e8.tar.bz2
More optimization of dumpsys output.
There are three major classes of changes here: - Avoid writing lines where their values are often empty, false, or some other typical thing. - Use partial writes to the PrintWriter to avoid creating temporary strings. - Use StringBuilder where we need to generate real String objects (and where possible cache the result).
Diffstat (limited to 'core/java/com/android')
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java43
1 files changed, 23 insertions, 20 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 58a9be85..77649f0 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -25,6 +25,7 @@ import android.os.Process;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.util.Log;
+import android.util.PrintWriterPrinter;
import android.util.Printer;
import android.util.SparseArray;
@@ -32,6 +33,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -3096,32 +3098,33 @@ public final class BatteryStatsImpl extends BatteryStats {
}
};
- public void dumpLocked(Printer pw) {
+ public void dumpLocked(PrintWriter pw) {
if (DEBUG) {
- pw.println("*** Screen timer:");
- mScreenOnTimer.logState(pw, " ");
+ Printer pr = new PrintWriterPrinter(pw);
+ pr.println("*** Screen timer:");
+ mScreenOnTimer.logState(pr, " ");
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
- pw.println("*** Screen brightness #" + i + ":");
- mScreenBrightnessTimer[i].logState(pw, " ");
+ pr.println("*** Screen brightness #" + i + ":");
+ mScreenBrightnessTimer[i].logState(pr, " ");
}
- pw.println("*** Input event counter:");
- mInputEventCounter.logState(pw, " ");
- pw.println("*** Phone timer:");
- mPhoneOnTimer.logState(pw, " ");
+ pr.println("*** Input event counter:");
+ mInputEventCounter.logState(pr, " ");
+ pr.println("*** Phone timer:");
+ mPhoneOnTimer.logState(pr, " ");
for (int i=0; i<NUM_SIGNAL_STRENGTH_BINS; i++) {
- pw.println("*** Signal strength #" + i + ":");
- mPhoneSignalStrengthsTimer[i].logState(pw, " ");
+ pr.println("*** Signal strength #" + i + ":");
+ mPhoneSignalStrengthsTimer[i].logState(pr, " ");
}
for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) {
- pw.println("*** Data connection type #" + i + ":");
- mPhoneDataConnectionsTimer[i].logState(pw, " ");
- }
- pw.println("*** Wifi timer:");
- mWifiOnTimer.logState(pw, " ");
- pw.println("*** WifiRunning timer:");
- mWifiRunningTimer.logState(pw, " ");
- pw.println("*** Bluetooth timer:");
- mBluetoothOnTimer.logState(pw, " ");
+ pr.println("*** Data connection type #" + i + ":");
+ mPhoneDataConnectionsTimer[i].logState(pr, " ");
+ }
+ pr.println("*** Wifi timer:");
+ mWifiOnTimer.logState(pr, " ");
+ pr.println("*** WifiRunning timer:");
+ mWifiRunningTimer.logState(pr, " ");
+ pr.println("*** Bluetooth timer:");
+ mBluetoothOnTimer.logState(pr, " ");
}
super.dumpLocked(pw);
}