Package bbejeck.nio.sockets

Examples of bbejeck.nio.sockets.PlainSocketMessageSender


public class AsyncSocketServerComparisonTest {


    @Test
    public void testAsyncSocketServer() throws Exception {
        PlainSocketMessageSender messageSender = new PlainSocketMessageSender(5000,10000,"localhost");
        final AsyncServerSocket serverSocket = new AsyncServerSocket(5000,"localhost");
        FutureTask<Long> asyncFutureTask = new FutureTask<>(new Callable<Long>() {
            @Override
            public Long call() throws Exception {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.start();
                serverSocket.startServer();
                stopwatch.stop();
                return stopwatch.elapsedTime(TimeUnit.SECONDS);
            }
        });
        System.out.println("Starting the AsyncSocketServer Test");
        new Thread(asyncFutureTask).start();
        Thread.sleep(1000);
        messageSender.sendMessages();
        Long time = asyncFutureTask.get();
        System.out.println("AsyncServer processed [10000] messages  in " + time+" seconds");
    }
View Full Code Here


    }
   
    @Test
    @Ignore
    public void testPlainSocketServer() throws Exception {
        PlainSocketMessageSender messageSender = new PlainSocketMessageSender(5001,10000,"localhost");
        final PlainServerSocket serverSocket = new PlainServerSocket(5001,"localhost");
        FutureTask<Long> plainFutureTask = new FutureTask<>(new Callable<Long>() {
            @Override
            public Long call() throws Exception {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.start();
                serverSocket.startServer();
                stopwatch.stop();
                return stopwatch.elapsedTime(TimeUnit.SECONDS);
            }
        });

        new Thread(plainFutureTask).start();
        Thread.sleep(1000);
        messageSender.sendMessages();
        Long time = plainFutureTask.get();
        System.out.println("PlainSocketServer processed [10000] messages  in " + time +" seconds");
    }
View Full Code Here

public class AsyncSocketTestDriver {


    public static void main(String[] args) throws Exception {
        Injector injector = Guice.createInjector(new SocketModule(), new PlainSocketModule(), new AsyncServerTestModule());
        PlainSocketMessageSender messageSender = injector.getInstance(PlainSocketMessageSender.class);
        final AsyncServerSocket asyncServerSocket = injector.getInstance(AsyncServerSocket.class);
        FutureTask<Long> asyncFutureTask = new FutureTask<>(new Callable<Long>() {
            @Override
            public Long call() throws Exception {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.start();
                asyncServerSocket.startServer();
                stopwatch.stop();
                return stopwatch.elapsedMillis();
            }
        });
        System.out.println("Starting the AsyncSocketServer Test");
        new Thread(asyncFutureTask).start();
        long sleepTime = 50;
        Thread.sleep(sleepTime);
        messageSender.sendMessages();
        Long time = asyncFutureTask.get();
        System.out.println("AsyncServer processed [10000] messages  in " + (time - sleepTime) + " millis");
    }
View Full Code Here

public class PlainSocketTestDriver {


    public static void main(String[] args) throws Exception {
        Injector injector = Guice.createInjector(new SocketModule(), new PlainSocketModule(), new AsyncServerTestModule());
        PlainSocketMessageSender messageSender = injector.getInstance(PlainSocketMessageSender.class);
        System.out.println("Starting the PlainSocketServer Test");
        final PlainServerSocket plainServerSocket = injector.getInstance(PlainServerSocket.class);
        FutureTask<Long> plainFutureTask = new FutureTask<>(new Callable<Long>() {
            @Override
            public Long call() throws Exception {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.start();
                plainServerSocket.startServer();
                stopwatch.stop();
                return stopwatch.elapsedMillis();
            }
        });

        new Thread(plainFutureTask).start();
        long sleepTime = 50;
        Thread.sleep(sleepTime);
        messageSender.sendMessages();
        Long time = plainFutureTask.get();
        System.out.println("PlainSocketServer processed [10000] messages  in " + (time - sleepTime) + " millis");
    }
View Full Code Here

TOP

Related Classes of bbejeck.nio.sockets.PlainSocketMessageSender

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.