20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.jfr.event.runtime;
27
28 import static jdk.test.lib.Asserts.assertTrue;
29
30 import java.time.Duration;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.Random;
34
35 import jdk.jfr.Recording;
36 import jdk.jfr.consumer.RecordedEvent;
37 import jdk.test.lib.jfr.EventNames;
38 import jdk.test.lib.jfr.Events;
39
40 /*
41 * @test
42 * @key jfr
43 * @library /test/lib
44 * @run main/othervm jdk.jfr.event.runtime.TestJavaThreadStatisticsEvent
45 */
46 public class TestJavaThreadStatisticsEvent {
47 private static final String EVENT_NAME = EventNames.JavaThreadStatistics;
48
49 private static final int THREAD_COUNT = 10;
50 private static final Random RAND = new Random(4711);
51
52 // verify thread count: 0 <= daemon <= active <= peak <= accumulated.
53 public static void main(String[] args) throws Throwable {
54 Recording recording = new Recording();
55 recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(10));
56 recording.start();
57
58 List<Thread> threads = new ArrayList<>();
59 for (int i = 0; i < THREAD_COUNT; i++) {
60 Thread thread = new Thread(TestJavaThreadStatisticsEvent::sleepRandom);
61 thread.start();
62 threads.add(thread);
|
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.jfr.event.runtime;
27
28 import static jdk.test.lib.Asserts.assertTrue;
29
30 import java.time.Duration;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.Random;
34
35 import jdk.jfr.Recording;
36 import jdk.jfr.consumer.RecordedEvent;
37 import jdk.test.lib.jfr.EventNames;
38 import jdk.test.lib.jfr.Events;
39
40 /**
41 * @test
42 * @key jfr
43 * @requires vm.hasJFR
44 * @library /test/lib
45 * @run main/othervm jdk.jfr.event.runtime.TestJavaThreadStatisticsEvent
46 */
47 public class TestJavaThreadStatisticsEvent {
48 private static final String EVENT_NAME = EventNames.JavaThreadStatistics;
49
50 private static final int THREAD_COUNT = 10;
51 private static final Random RAND = new Random(4711);
52
53 // verify thread count: 0 <= daemon <= active <= peak <= accumulated.
54 public static void main(String[] args) throws Throwable {
55 Recording recording = new Recording();
56 recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(10));
57 recording.start();
58
59 List<Thread> threads = new ArrayList<>();
60 for (int i = 0; i < THREAD_COUNT; i++) {
61 Thread thread = new Thread(TestJavaThreadStatisticsEvent::sleepRandom);
62 thread.start();
63 threads.add(thread);
|