diff options
Diffstat (limited to 'plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/Performance.java')
-rw-r--r-- | plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/Performance.java | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/Performance.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/Performance.java deleted file mode 100644 index 6b3a4572b4..0000000000 --- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/Performance.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.eclipse.net4j.tests; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.Proxy; -import java.net.ServerSocket; -import java.net.Socket; -import java.net.SocketAddress; -import java.nio.channels.Selector; -import java.nio.channels.spi.SelectorProvider; -import java.util.concurrent.CountDownLatch; - -/** - * @author Eike Stepper - */ -public class Performance -{ - public static void main(String[] args) throws Exception - { - testInetAddress(); - testServerSocket(); - // testRouter(); - testSocket(); - testSelector(); - } - - public static void testInetAddress() throws Exception - { - System.out.println(InetAddress.class.getName()); - for (int i = 0; i < 2; i++) - { - long start = System.currentTimeMillis(); - InetAddress inet = InetAddress.getByName("localhost"); - inet.getHostAddress(); - long duration = System.currentTimeMillis() - start; - - System.out.println(duration); - } - } - - public static void testServerSocket() throws IOException - { - System.out.println(ServerSocket.class.getName()); - for (int i = 0; i < 2; i++) - { - long start = System.currentTimeMillis(); - ServerSocket serverSocket = new ServerSocket(2036); - long duration = System.currentTimeMillis() - start; - - System.out.println(duration); - serverSocket.close(); - } - } - - public static void testRouter() throws Exception - { - System.out.println(Socket.class.getName() + " (ROUTER)"); - for (int i = 0; i < 2; i++) - { - final SocketAddress endpoint = new InetSocketAddress(InetAddress.getByName("192.168.1.1"), 80); - Socket socket = new Socket(Proxy.NO_PROXY); - - long start = System.currentTimeMillis(); - socket.connect(endpoint); - long duration = System.currentTimeMillis() - start; - - System.out.println(duration); - socket.close(); - Thread.sleep(500); - } - } - - public static void testSocket() throws Exception - { - System.out.println(Socket.class.getName() + " (LOOPBACK)"); - for (int i = 0; i < 2; i++) - { - final SocketAddress endpoint = new InetSocketAddress(InetAddress.getByName("127.0.0.1"), 2036); - final CountDownLatch latch = new CountDownLatch(1); - new Thread() - { - @Override - public void run() - { - try - { - ServerSocket serverSocket = new ServerSocket(); - serverSocket.bind(endpoint); - latch.countDown(); - - Socket socket = serverSocket.accept(); - socket.close(); - serverSocket.close(); - } - catch (IOException ex) - { - ex.printStackTrace(); - latch.countDown(); - } - } - }.start(); - - latch.await(); - Thread.sleep(500); - Socket socket = new Socket(Proxy.NO_PROXY); - - long start = System.currentTimeMillis(); - socket.connect(endpoint); - long duration = System.currentTimeMillis() - start; - - System.out.println(duration); - socket.close(); - Thread.sleep(500); - } - } - - public static void testSelector() throws IOException - { - SelectorProvider provider = SelectorProvider.provider(); - System.out.println(provider.getClass().getName()); - for (int i = 0; i < 2; i++) - { - long start = System.currentTimeMillis(); - Selector selector = provider.openSelector(); - long duration = System.currentTimeMillis() - start; - - System.out.println(duration); - selector.close(); - } - } -} |