summaryrefslogtreecommitdiff
path: root/tools/ahat/test/PerformanceTest.java
diff options
context:
space:
mode:
author Richard Uhler <ruhler@google.com> 2015-10-29 14:55:00 -0700
committer Richard Uhler <ruhler@google.com> 2015-11-03 11:11:57 -0800
commit1af86f17dc9a47faf1c6cd7ccd23d248fdc615ab (patch)
tree22796622e72c8381bbb26d15c3f7dd35584dbdb2 /tools/ahat/test/PerformanceTest.java
parent530dcc8b74a0f4e5f54e2b2c326580d58594a2f7 (diff)
ahat: limit default number of results shown.
Previously, ahat had performance issues rendering large pages. This change causes ahat to limit the number results shown in large pages by default, requiring the user to explicitly request more information if they care about it. Bug: 25114227 Change-Id: Ief67396be254be4c84e6971f5b903a701206e17b
Diffstat (limited to 'tools/ahat/test/PerformanceTest.java')
-rw-r--r--tools/ahat/test/PerformanceTest.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/ahat/test/PerformanceTest.java b/tools/ahat/test/PerformanceTest.java
new file mode 100644
index 0000000000..6e46800603
--- /dev/null
+++ b/tools/ahat/test/PerformanceTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 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 com.android.ahat;
+
+import com.android.tools.perflib.heap.Instance;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+public class PerformanceTest {
+ private static class NullOutputStream extends OutputStream {
+ public void write(int b) throws IOException {
+ }
+ }
+
+ @Test
+ public void bigArray() throws IOException {
+ // It should not take more than 1 second to load the default object view
+ // for any object, including big arrays.
+ TestDump dump = TestDump.getTestDump();
+
+ Instance bigArray = (Instance)dump.getDumpedThing("bigArray");
+ assertNotNull(bigArray);
+
+ AhatSnapshot snapshot = dump.getAhatSnapshot();
+ AhatHandler handler = new ObjectHandler(snapshot);
+
+ PrintStream ps = new PrintStream(new NullOutputStream());
+ HtmlDoc doc = new HtmlDoc(ps, DocString.text("bigArray test"), DocString.uri("style.css"));
+ String uri = "http://localhost:7100/object?id=" + bigArray.getId();
+ Query query = new Query(DocString.uri(uri));
+
+ long start = System.currentTimeMillis();
+ handler.handle(doc, query);
+ long time = System.currentTimeMillis() - start;
+ assertTrue("bigArray took too long: " + time + "ms", time < 1000);
+ }
+}