diff options
author | Makoto Onuki <omakoto@google.com> | 2017-06-28 12:10:47 -0700 |
---|---|---|
committer | Makoto Onuki <omakoto@google.com> | 2017-06-28 20:23:46 +0000 |
commit | f6d6e9ecd77bc55614c6bc31340fd5f1cb2a9afb (patch) | |
tree | c662a20708b0d3512cba5bcc8f6a7fbb5e683d72 | |
parent | 7d2d194ec126edf882f34ad3cf0dc8f0e95d3a82 (diff) |
Sort INSTRUMENTATION_STATUS keys on am instrument output
Previously the output from perftests was printed in a random order:
INSTRUMENTATION_STATUS: timeGetDataCapacity_standardDeviation=5
INSTRUMENTATION_STATUS: timeGetDataCapacity_median=486
INSTRUMENTATION_STATUS: timeGetDataCapacity_mean=489
INSTRUMENTATION_STATUS: timeGetDataCapacity_min=484
INSTRUMENTATION_STATUS_CODE: -1
Now it's always printed in the same (sorted) order.
INSTRUMENTATION_STATUS: timeGetDataCapacity_mean=489
INSTRUMENTATION_STATUS: timeGetDataCapacity_median=486
INSTRUMENTATION_STATUS: timeGetDataCapacity_min=484
INSTRUMENTATION_STATUS: timeGetDataCapacity_standardDeviation=5
INSTRUMENTATION_STATUS_CODE: -1
Test: manual test
Change-Id: I807aa05e6523b70a132ab97fc099156bb3dc1f96
-rw-r--r-- | cmds/am/src/com/android/commands/am/Instrument.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/cmds/am/src/com/android/commands/am/Instrument.java b/cmds/am/src/com/android/commands/am/Instrument.java index 4966b4380d9b..c6d83f51a40a 100644 --- a/cmds/am/src/com/android/commands/am/Instrument.java +++ b/cmds/am/src/com/android/commands/am/Instrument.java @@ -25,7 +25,6 @@ import android.content.pm.IPackageManager; import android.content.pm.InstrumentationInfo; import android.os.Build; import android.os.Bundle; -import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.util.AndroidException; @@ -34,6 +33,8 @@ import android.view.IWindowManager; import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.List; @@ -95,6 +96,12 @@ public class Instrument { public void onError(String errorText, boolean commandError); } + private static Collection<String> sorted(Collection<String> list) { + final ArrayList<String> copy = new ArrayList<>(list); + Collections.sort(copy); + return copy; + } + /** * Printer for the 'classic' text based status reporting. */ @@ -124,7 +131,7 @@ public class Instrument { System.out.print(pretty); } else { if (results != null) { - for (String key : results.keySet()) { + for (String key : sorted(results.keySet())) { System.out.println( "INSTRUMENTATION_STATUS: " + key + "=" + results.get(key)); } @@ -214,7 +221,7 @@ public class Instrument { private void writeBundle(ProtoOutputStream proto, long fieldId, Bundle bundle) { final long bundleToken = proto.startObject(fieldId); - for (final String key: bundle.keySet()) { + for (final String key: sorted(bundle.keySet())) { final long entryToken = proto.startRepeatedObject( InstrumentationData.ResultsBundle.ENTRIES); |