< prev index next >
test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/heap/HeapWalkTests.java
Print this page
rev 58143 : imported patch test_heap_walk
@@ -29,10 +29,11 @@
package nsk.jvmti.unit.heap;
import nsk.share.jvmti.unit.*;
import java.io.PrintStream;
+import java.util.*;
public class HeapWalkTests {
final static int JCK_STATUS_BASE = 95;
final static int PASSED = 0;
@@ -44,13 +45,16 @@
// produce JCK-like exit status.
System.exit(run(args, System.out) + JCK_STATUS_BASE);
}
public static int run(String args[], PrintStream out) {
- test1();
+/* test1();
test2();
test3();
+
+ */
+ test4();
return PASSED;
}
private static void test1() {
long tag;
@@ -154,6 +158,29 @@
if (failures > 0) {
throw new RuntimeException("IterateOverObjectsReachableFromObject test failed");
}
}
+
+ static final long TARGET_OBJECTS = 300_000;
+
+ private static void test4() {
+ ArrayList<ArrayList<Foo>> objects = new ArrayList<>();
+ long cnt = 0;
+ Random r = new Random();
+ while (cnt < TARGET_OBJECTS) {
+ int current = r.nextInt(2_000);
+ ArrayList<Foo> list = new ArrayList<>(current);
+ for (int index = 0; index < current; index ++) {
+ list.add(new Foo());
+ }
+ objects.add(list);
+ cnt += current;
+ }
+
+ long start = System.nanoTime();
+ Heap.iterateOverObjectsReachableFromObject(objects);
+ long end = System.nanoTime();
+
+ System.out.println("\nTime: " + (end - start) + " nsecs");
+ }
}
< prev index next >