package org.javamexico.protobuf.example;

import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricRegistry;
import org.javamexico.service.Servicio;
import org.javamexico.ws.example.ClienteWS;
import org.javamexico.ws.example.WebService;

import javax.xml.ws.Endpoint;
import java.util.concurrent.TimeUnit;

/**
 * Clase principal para correr la demo.
 *
 * @author Enrique Zamudio
 *         Date: 3/21/17 11:54 AM
 */
public class Main {

    private final static Servicio servicio = new Servicio();
    public static final MetricRegistry METRICS = new MetricRegistry();
    public static final int ROUNDS = 50000;

    private static void proto() throws Exception {
        ProtoServer server = new ProtoServer(servicio);
        Thread t = new Thread(server, "proto-server");
        t.start();
        //Crear un cliente y enviar N peticiones
        final ProtoClient pc = new ProtoClient();
        pc.writeToDisk();
        pc.benchmark(1000);
        METRICS.timer("proto.total").time(() -> pc.benchmark(Main.ROUNDS));
        server.shutdown();
    }

    private static void ws() throws Exception {
        WebService ws = new WebService();
        ws.setService(servicio);
        Endpoint endpoint = Endpoint.create(ws);
        endpoint.publish("http://localhost:9998/ws");
        ClienteWS wsc = new ClienteWS();
        System.out.println("WS warmup");
        wsc.benchmark(1000);
        System.out.println("WS benchmark");
        METRICS.timer("ws.total").time(() -> wsc.benchmark(Main.ROUNDS));
    }

    public static void main(String... args) throws Exception {
        proto();
        ws();
        ConsoleReporter.forRegistry(Main.METRICS).convertDurationsTo(TimeUnit.MILLISECONDS)
                .convertRatesTo(TimeUnit.SECONDS).outputTo(System.out).build().report();
        System.out.println("FYI, " + Runtime.getRuntime().availableProcessors() + " CPUs");
        System.exit(0);
    }

}

@@ -284,16 +284,83 @@
 dpoint;%0A
+import java.io.InputStreamReader;%0Aimport java.io.LineNumberReader;%0A
 import j
@@ -700,16 +700,346 @@
 50000;%0A%0A
+    private static void externalTest() throws Exception %7B%0A        ProtoServer server = new ProtoServer(servicio);%0A        Thread t = new Thread(server, %22proto-server%22);%0A        t.start();%0A        System.out.println(%22LISTO; dale ENTER para terminar%22);%0A        synchronized(servicio) %7B%0A            servicio.wait();%0A        %7D%0A    %7D%0A%0A
     priv
@@ -2007,21 +2007,18 @@
         
-proto
+ws
 ();%0A    
@@ -2013,34 +2013,37 @@
   ws();%0A        
-ws
+proto
 ();%0A        Cons
@@ -2299,24 +2299,48 @@
 + %22 CPUs%22);%0A
+        externalTest();%0A
         Syst

Add a method for external testing