summaryrefslogtreecommitdiffstats
path: root/dalvik/src/test
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2010-07-23 15:57:52 -0700
committerBrian Carlstrom <bdc@google.com>2010-09-01 10:16:51 -0700
commit51ee38b9c39b0c36bce728a797b2c5e637be3d2c (patch)
tree166bff5a21e0d994eed4a12c98a6499876703c27 /dalvik/src/test
parent5b65f4f2917a11ef9d2798203f5dca55682d9e81 (diff)
downloadlibcore-51ee38b9c39b0c36bce728a797b2c5e637be3d2c.zip
libcore-51ee38b9c39b0c36bce728a797b2c5e637be3d2c.tar.gz
libcore-51ee38b9c39b0c36bce728a797b2c5e637be3d2c.tar.bz2
New Java-based SamplingProfiler
Summary: - libcore: new Java based SamplingProfiler - dalvik: remove old SamplingProfiler native bits - frameworks/base: New placeholder SamplingProfilerIntegration - vendor/google: remove old profiler snapshot parsing code Details: libcore A new 100% Java SamplingProfiler. While it has more overhead that the old native one, the new one can actually collect more than the current PC and frame pointer, so you can get useful context of where your app is spending time. It currently provides ASCII hprof format output for use with tools like PerfAnal dalvik/src/main/java/dalvik/system/SamplingProfiler.java Unit test for the new SamplingProfiler dalvik/src/test/java/dalvik/system/SamplingProfilerTest.java Add core-tests-dalvik JavaLibrary.mk dalvik Removing native code that supported the old SamplingProfiler vm/Dvm.mk vm/native/InternalNative.c vm/native/dalvik_system_SamplingProfiler.c frameworks/base Placeholder SamplingProfilerIntegration. Later plans include generating EventStackTrace protobufs. New SamplingProfiler does not have a global instance, so SamplingProfilerIntegration provides one in INSTANCE. Old binary snapshot format is temporily replaced with ASCII hprof data. core/java/com/android/internal/os/SamplingProfilerIntegration.java Simplified interface for zygote profile snapshotting core/java/com/android/internal/os/ZygoteInit.java Current SamplingProfilerIntegration does not track event loop explicitly, but hprof information does include thread information. core/java/android/app/ActivityThread.java vendor/google Removing code for parsing old SamplingProfiler snapshot format tools/samplingprofiler/Android.mk tools/samplingprofiler/NOTICE tools/samplingprofiler/profiler.iml tools/samplingprofiler/profiler.ipr tools/samplingprofiler/pull-snapshots.sh tools/samplingprofiler/sorttable.js tools/samplingprofiler/src/com/android/profiler/PrintHtml.java
Diffstat (limited to 'dalvik/src/test')
-rw-r--r--dalvik/src/test/java/dalvik/system/SamplingProfilerTest.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/dalvik/src/test/java/dalvik/system/SamplingProfilerTest.java b/dalvik/src/test/java/dalvik/system/SamplingProfilerTest.java
new file mode 100644
index 0000000..42057c8
--- /dev/null
+++ b/dalvik/src/test/java/dalvik/system/SamplingProfilerTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dalvik.system;
+
+import dalvik.system.SamplingProfiler.ThreadSet;
+import java.math.BigInteger;
+import java.security.KeyPairGenerator;
+import java.security.SecureRandom;
+import javax.crypto.spec.DHParameterSpec;
+import junit.framework.TestCase;
+
+public class SamplingProfilerTest extends TestCase {
+
+ public void test_SamplingProfiler_basic() throws Exception {
+ ThreadSet threadSet = SamplingProfiler.newArrayThreadSet(Thread.currentThread());
+ SamplingProfiler profiler = new SamplingProfiler(12, threadSet);
+ profiler.start(10);
+ toBeMeasured();
+ profiler.stop();
+ profiler.shutdown();
+ profiler.writeHprofData(System.out);
+ }
+
+ private static final String P_STR =
+ "9494fec095f3b85ee286542b3836fc81a5dd0a0349b4c239dd38744d488cf8e3"
+ + "1db8bcb7d33b41abb9e5a33cca9144b1cef332c94bf0573bf047a3aca98cdf3b";
+ private static final String G_STR =
+ "98ab7c5c431479d8645e33aa09758e0907c78747798d0968576f9877421a9089"
+ + "756f7876e76590b76765645c987976d764dd4564698a87585e64554984bb4445"
+ + "76e5764786f875b4456c";
+
+ private static final byte[] P = new BigInteger(P_STR,16).toByteArray();
+ private static final byte[] G = new BigInteger(G_STR,16).toByteArray();
+
+ private static void toBeMeasured () throws Exception {
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < 10000; i++) {
+ BigInteger p = new BigInteger(P);
+ BigInteger g = new BigInteger(G);
+ KeyPairGenerator gen = KeyPairGenerator.getInstance("DH");
+ gen.initialize(new DHParameterSpec(p, g), new SecureRandom());
+ }
+ long end = System.currentTimeMillis();
+ }
+
+}