PrivilegedSocketOperationsBenchmark Class — netty Architecture
Architecture documentation for the PrivilegedSocketOperationsBenchmark class in PrivilegedSocketOperationsBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD f3db0f7f_b7c4_a21d_9362_5d141ce5d00d["PrivilegedSocketOperationsBenchmark"] 28118feb_7948_ce3a_e892_3715590e8432["PrivilegedSocketOperationsBenchmark.java"] f3db0f7f_b7c4_a21d_9362_5d141ce5d00d -->|defined in| 28118feb_7948_ce3a_e892_3715590e8432 7357d5d7_0023_f448_dcea_1e08668a5f82["ServerSocketChannel()"] f3db0f7f_b7c4_a21d_9362_5d141ce5d00d -->|method| 7357d5d7_0023_f448_dcea_1e08668a5f82
Relationship Graph
Source Code
microbench/src/main/java/io/netty/microbench/internal/PrivilegedSocketOperationsBenchmark.java lines 40–193
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
public class PrivilegedSocketOperationsBenchmark extends AbstractMicrobenchmark {
@State(Scope.Benchmark)
public static class SecurityManagerInstalled {
@Setup
public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException {
final URI policyFile = PrivilegedSocketOperationsBenchmark.class.getResource("/jmh-security.policy")
.toURI();
Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile)));
System.setSecurityManager(new SecurityManager());
}
@TearDown
public void tearDown() throws IOException {
System.setSecurityManager(null);
}
}
@State(Scope.Benchmark)
public static class SecurityManagerEmpty {
@Setup
public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException {
System.setSecurityManager(null);
}
}
@Benchmark
public ServerSocketChannel testWithSMNoPrivileged(final SecurityManagerInstalled sm) throws IOException {
final ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.socket().bind(null);
ssc.configureBlocking(false);
ssc.accept();
ssc.close();
return ssc;
}
@Benchmark
public ServerSocketChannel testWithSM(final SecurityManagerInstalled sm) throws IOException {
try {
final ServerSocketChannel ssc = AccessController.doPrivileged(
new PrivilegedExceptionAction<ServerSocketChannel>() {
@Override
public ServerSocketChannel run() throws Exception {
final ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.socket().bind(null);
ssc.configureBlocking(false);
ssc.accept();
return ssc;
}
});
ssc.close();
return ssc;
} catch (final PrivilegedActionException e) {
throw (IOException) e.getCause();
}
}
@Benchmark
public ServerSocketChannel testWithSMWithNullCheck(final SecurityManagerInstalled sm) throws IOException {
if (System.getSecurityManager() != null) {
try {
final ServerSocketChannel ssc = AccessController.doPrivileged(
new PrivilegedExceptionAction<ServerSocketChannel>() {
@Override
public ServerSocketChannel run() throws Exception {
final ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.socket().bind(null);
ssc.configureBlocking(false);
ssc.accept();
return ssc;
}
});
ssc.close();
return ssc;
} catch (final PrivilegedActionException e) {
throw (IOException) e.getCause();
}
Defined In
Source
Frequently Asked Questions
What is the PrivilegedSocketOperationsBenchmark class?
PrivilegedSocketOperationsBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/internal/PrivilegedSocketOperationsBenchmark.java.
Where is PrivilegedSocketOperationsBenchmark defined?
PrivilegedSocketOperationsBenchmark is defined in microbench/src/main/java/io/netty/microbench/internal/PrivilegedSocketOperationsBenchmark.java at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free