This is an automated email from the ASF dual-hosted git repository. jtulach pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new e9b28713a3 Including additional methods into knownBLockingMethods to match classes as of JDK-11 new ff09cf74c3 Merge pull request #4168 from jtulach/jtulach/MoreKnownBlockingMethods e9b28713a3 is described below commit e9b28713a3b62021a4dc58f3db53ba1c46c206e0 Author: Jaroslav Tulach <jaroslav.tul...@apidesign.org> AuthorDate: Sat May 28 08:26:05 2022 +0200 Including additional methods into knownBLockingMethods to match classes as of JDK-11 --- .travis.yml | 1 + .../results/cpu/StackTraceSnapshotBuilder.java | 6 ++ .../modules/profiler/SampledCPUSnapshotTest.java | 85 +++++++++++++++++++++ .../netbeans/modules/profiler/jdk11-sample1.npss | Bin 0 -> 30502 bytes 4 files changed, 92 insertions(+) diff --git a/.travis.yml b/.travis.yml index cb35d64a56..d654370c08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -495,6 +495,7 @@ matrix: - nbbuild/travis/ant.sh $OPTS build script: - ant $OPTS -f profiler/profiler.oql test + - ant $OPTS -f profiler/profiler test-unit - name: Test webcommon modules jdk: openjdk8 diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/results/cpu/StackTraceSnapshotBuilder.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/results/cpu/StackTraceSnapshotBuilder.java index 0f1d3e0d80..2ead829cff 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/results/cpu/StackTraceSnapshotBuilder.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/results/cpu/StackTraceSnapshotBuilder.java @@ -77,8 +77,14 @@ public class StackTraceSnapshotBuilder { new MethodInfo("sun.nio.ch.KQueueArrayWrapper","kevent0[native](int, long, int, long) : int"), // NOI18N new MethodInfo("sun.nio.ch.WindowsSelectorImpl$SubSelector","poll0[native]"), // NOI18N new MethodInfo("sun.nio.ch.WindowsSelectorImpl$SubSelector","poll0[native](long, int, int[], int[], int[], long) : int"), // NOI18N + new MethodInfo("sun.nio.ch.EPoll","wait[native]"), // NOI18N new MethodInfo("java.net.PlainSocketImpl", "socketConnect[native]"), // NOI18N new MethodInfo("java.net.PlainSocketImpl", "socketConnect[native](java.net.InetAddress, int, int) : void"), // NOI18N + new MethodInfo("java.net.SocketInputStream", "socketRead0[native]"), // NOI18N + new MethodInfo("jdk.internal.misc.Unsafe", "park[native]"), // NOI18N + new MethodInfo("java.lang.ref.Reference", "waitForReferencePendingList[native]"), // NOI18N + new MethodInfo("java.io.FileInputStream", "readBytes[native]"), // NOI18N + new MethodInfo("sun.management.ThreadImpl", "dumpThreads0[native]"), // NOI18N }); private InstrumentationFilter filter; diff --git a/profiler/profiler/test/unit/src/org/netbeans/modules/profiler/SampledCPUSnapshotTest.java b/profiler/profiler/test/unit/src/org/netbeans/modules/profiler/SampledCPUSnapshotTest.java new file mode 100644 index 0000000000..898b7692ac --- /dev/null +++ b/profiler/profiler/test/unit/src/org/netbeans/modules/profiler/SampledCPUSnapshotTest.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.netbeans.modules.profiler; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Map; +import java.util.TreeMap; +import org.junit.Test; +import static org.junit.Assert.*; +import org.netbeans.lib.profiler.results.ResultsSnapshot; +import org.netbeans.lib.profiler.results.cpu.CPUCCTContainer; +import org.netbeans.lib.profiler.results.cpu.CPUResultsSnapshot; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +public class SampledCPUSnapshotTest { + + public SampledCPUSnapshotTest() { + } + + @Test + public void testGetCPUSnapshot() throws Exception { + final String name = "jdk11-sample1.npss"; + final SampledCPUSnapshot snapshot = loadSnapshot(name); + assertEquals(442, snapshot.getSamplesCount()); + + LoadedSnapshot interval = snapshot.getCPUSnapshot(88, 103); + Map<String, Long> timesByThreadName = timesByThreadName(interval); + + assertEquals(Long.valueOf(5053), timesByThreadName.remove("command-pool-6")); + assertEquals(Long.valueOf(5053), timesByThreadName.remove("logging-service-client-akka.actor.default-dispatcher-5")); + assertEquals(Long.valueOf(4151), timesByThreadName.remove("pool-2-thread-1")); + assertEquals(Long.valueOf(5506), timesByThreadName.remove("scala-execution-context-global-57")); + assertEquals(Long.valueOf(10788), timesByThreadName.remove("searcher.db-1")); + assertEquals(Long.valueOf(50314), timesByThreadName.remove("job-pool-1")); + + assertTrue("No other threads working: " + timesByThreadName, timesByThreadName.isEmpty()); + } + + private static Map<String, Long> timesByThreadName(LoadedSnapshot interval) { + ResultsSnapshot result = interval.getSnapshot(); + assertEquals(CPUResultsSnapshot.class, result.getClass()); + Map<String,Long> timesByThreadName = new TreeMap<>(); + CPUResultsSnapshot cpu = (CPUResultsSnapshot) result; + for (int id : cpu.getThreadIds()) { + String threadName = cpu.getThreadNameForId(id); + CPUCCTContainer container = cpu.getContainerForThread(id, 0); + long t1 = container.getWholeGraphNetTime1(); + if (t1 > 0) { + Long prev = timesByThreadName.put(threadName, t1); + assertNull("There should be just a single " + threadName, prev); + } + } + return timesByThreadName; + } + + private static SampledCPUSnapshot loadSnapshot(final String name) throws IOException { + InputStream is = SampledCPUSnapshotTest.class.getResourceAsStream(name); + assertNotNull("Sample npss file found", is); + FileObject sample = FileUtil.createMemoryFileSystem().getRoot().createData("sample.npss"); + try (OutputStream os = sample.getOutputStream()) { + FileUtil.copy(is, os); + } + return new SampledCPUSnapshot(sample); + } + +} diff --git a/profiler/profiler/test/unit/src/org/netbeans/modules/profiler/jdk11-sample1.npss b/profiler/profiler/test/unit/src/org/netbeans/modules/profiler/jdk11-sample1.npss new file mode 100644 index 0000000000..cd8ed663b1 Binary files /dev/null and b/profiler/profiler/test/unit/src/org/netbeans/modules/profiler/jdk11-sample1.npss differ --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists