public static void runOneTest()

in benchmark/benchmark1/src/org/apache/cxf/performance/client/BenchClient.java [205:506]


    public static void runOneTest(TestDescriptor td)
            throws Exception {
        final char direction = td.direction;
        final char method = td.method;
        //int arrSize = method == 'v' ? 1 : td.arrSizeToSend;
        int arrSize = td.arrSizeToSend;
        int N = td.elementsToSend / arrSize; // + 1;
        if (N == 0) {
            N = 1;
        }
        final boolean smokeTest = System.getProperty(SMOKE_TEST) != null;
        if (smokeTest) N = 3;

        int totalInv = N * td.arrSizeToSend;

        byte[] barr = null;
        byte[] ba = null;
        if (method == 'b') {
            ba = new byte[td.arrSizeToSend];
            barr = new byte[totalInv];
            for (int i = 0; i < barr.length; i++) {
                barr[i] = (byte) i;
            }
        }

        Double[] darr = null;
        if (method == 'd') {
            darr = new Double[totalInv];
            for (int i = 0; i < darr.length; i++) {
                darr[i] = Double.valueOf(i);
            }
        }

        Integer[] iarr = null;
        if (method == 'i') {
            iarr = new Integer[totalInv];
            for (int i = 0; i < iarr.length ; i++) {
                iarr[i] = Integer.valueOf(i);
            }
        }

        String[] sarr = null;
        if (method == 's') {
            sarr = new String[totalInv];
            for (int i = 0; i < sarr.length; i++) {
                sarr[i] = "s" + i;
            }
        }

        MeshInterfaceObject[] marr = null;
        if (method == 'm') {
            marr = new MeshInterfaceObject[totalInv];
            for (int i = 0; i < totalInv; i++) {
            	marr[i] = new MeshInterfaceObject();
                marr[i].setX(i);
                marr[i].setY(i);
                marr[i].setValue(Math.sqrt(i));
            }
        }

        SimpleEvent[] earr = null;
        if (method == 'e') {
            earr = new SimpleEvent[totalInv];
            for (int i = 0; i < earr.length; i++) {
                earr[i] = new SimpleEvent();
                earr[i].setSequenceNumber(i);
                earr[i].setMessage("Message #"+i);
                earr[i].setTimestamp(Math.sqrt(i));
            }
        }

        BenchClient client = new BenchClient(td.serverLocation);

//        System.out.println("invoking " + N + (smokeTest ? " (SMOKE TEST)" : "")
//                + " times for test " + method + " arraysSize=" + td.arrSizeToSend
//                + " " + (new Date()));
        //boolean validate = true;
        long start = System.currentTimeMillis();
        for (int count = 0; count < N; count++) {
            int off = count * arrSize;
            //String arg = "echo"+i;
            if (method == 'v') {
                if (direction == 'e') {
                    client.echoVoid();
                } else if (direction == 'r' || direction == 's') {
                    throw new RuntimeException("usupported direction " + direction + " for void method");
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
            } else if (method == 'b') {
            	System.arraycopy(barr, off, ba, 0, ba.length);
                byte[] uba = null;
                int ulen = -1;
                if (direction == 'e') {
                    uba = client.echoBase64(ba);
                } else if (direction == 'r') {
                    ulen = client.receiveBase64(ba);
                    if (ulen != ba.length) fail(method2s(direction, method) + " returned wrong size");
                } else if (direction == 's') {
                    uba = client.sendBase64(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if ((count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force
                    if (direction == 's') off = 0;
                    if (uba == null) fail(method2s(direction, method) + " byte array response was null");
                    if (uba.length != ba.length) {
                        fail(method2s(direction, method) + " byte array had wrong size " + uba.length
                                + " (expected " + ba.length + ")");
                    }
                    for (int i = 0; i < ba.length; i++) {
                        if (uba[i] != barr[i + off]) {
                            fail("byte array response had wrong content");
                        }
                    }
                }
            } else if (method == 'd') {
            	ArrayList<Double> da = new ArrayList<>();
            	new Util<Double>().copyList(darr, off, da, td.arrSizeToSend);
                List<Double> uda = null;
                int dlen = -1;
                if (direction == 'e') {
                    uda = client.echoDoubles(da);
                } else if (direction == 'r') {
                    dlen = client.receiveDoubles(da);
                    if (dlen != da.size()) fail("receive double array returned wrong size");
                } else if (direction == 's') {
                    uda = client.sendDoubles(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if ((count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (uda == null) fail(method2s(direction, method) + " double array response was null");
                    if (uda.size() != da.size()) {
                        fail(method2s(direction, method) + " double array had wrong size " + uda.size()
                                + " (expected " + da.size() + ")");
                    }
                    for (int i = 0; i < uda.size(); i++) {
                        if (uda.get(i) != darr[i + off]) {
                            fail(method2s(direction, method) + " double array response had wrong content");
                        }
                    }
                }
            } else if (method == 'i') {
            	ArrayList<Integer> ia = new ArrayList<>();
            	new Util<Integer>().copyList(iarr, off, ia, td.arrSizeToSend);
                List<Integer> uia = null;
                int ulen = -1;
                if (direction == 'e') {
                    uia = client.echoInts(ia);
                } else if (direction == 'r') {
                    ulen = client.receiveInts(ia);
                    if (ulen != ia.size()) {
                        fail(method2s(direction, method) + " receive byte array returned wrong size");
                    }
                } else if (direction == 's') {
                    uia = client.sendInts(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if ((count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (uia == null) fail(method2s(direction, method) + " int array response was null");
                    if (uia.size() != ia.size()) {
                        fail(method2s(direction, method) + " int array had wrong size " + uia.size()
                                + " (expected " + ia.size() + ")");
                    }
                    for (int i = 0; i < uia.size(); i++) {
                        if (uia.get(i) != iarr[i + off]) {
                            fail(method2s(direction, method) + " int array response had wrong content");
                        }
                    }
                }
            } else if (method == 's') {
            	ArrayList<String> sa = new ArrayList<>();
            	new Util<String>().copyList(sarr, off, sa, td.arrSizeToSend);
                List<String> usa = null;
                int slen = -1;
                if (direction == 'e') {
                    usa = client.echoStrings(sa);
                } else if (direction == 'r') {
                    slen = client.receiveStrings(sa);
                    if (slen != sa.size())
                        fail(method2s(direction, method) + " receive string array returned wrong size");
                } else if (direction == 's') {
                    usa = client.sendStrings(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if (start > 0 && (count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (usa == null) fail(method2s(direction, method) + " string array response was null");
                    if (usa.size() != sa.size()) {
                        fail(method2s(direction, method) + " string array had wrong size " + usa.size()
                                + " (expected " + sa.size() + ")");
                    }
                    for (int i = 0; i < usa.size(); i++) {
                        String s1 = usa.get(i);
                        String s2 = sarr[i + off];
                        if (!s1.equals(s2)) {
                            fail(method2s(direction, method) + " string array response"
                                    + " had wrong content (s1=" + s1 + " s2=" + s2 + " i=" + i + ")");
                        }
                    }
                }
            } else if (method == 'm') {
            	ArrayList<MeshInterfaceObject> ma = new ArrayList<>();
            	new Util<MeshInterfaceObject>().copyList(marr, off, ma, td.arrSizeToSend);
                List<MeshInterfaceObject> uma = null;
                int slen = -1;
                if (direction == 'e') {
                    uma = client.echoMeshInterfaceObjects(ma);
                } else if (direction == 'r') {
                    slen = client.receiveMeshInterfaceObjects(ma);
                    if (slen != ma.size())
                        fail(method2s(direction, method) + " receive MeshInterfaceObject array returned wrong size");
                } else if (direction == 's') {
                    uma = client.sendMeshInterfaceObjects(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if (start > 0 && (count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (uma == null) fail(method2s(direction, method) + " MeshInterfaceObject array response was null");
                    if (uma.size() != ma.size()) {
                        fail(method2s(direction, method) + " string MeshInterfaceObject had wrong size " + uma.size()
                                + " (expected " + ma.size() + ")");
                    }
                    for (int i = 0; i < uma.size(); i++) {
                        MeshInterfaceObject s1 = uma.get(i);
                        MeshInterfaceObject s2 = marr[i + off];
                        if (!toString(s1).equals(toString(s2))) {
                            fail(method2s(direction, method) + " MeshInterfaceObject array response"
                                    + " had wrong content (s1=" + s1 + " s2=" + s2 + " i=" + i + ")");
                        }
                    }
                }
            } else if (method == 'e') {
            	ArrayList<SimpleEvent> ea = new ArrayList<>();
            	new Util<SimpleEvent>().copyList(earr, off, ea, td.arrSizeToSend);
                List<SimpleEvent> uea = null;
                int slen = -1;
                if (direction == 'e') {
                    uea = client.echoSimpleEvents(ea);
                } else if (direction == 'r') {
                    slen = client.receiveSimpleEvents(ea);
                    if (slen != ea.size())
                        fail(method2s(direction, method) + " receive SimpleEvent array returned wrong size");
                } else if (direction == 's') {
                    uea = client.sendSimpleEvents(arrSize);
                } else {
                    throw new RuntimeException("unrecongized direction " + direction);
                }
                if (start > 0 && (count == 0 || count == N - 1) && (direction == 'e' || direction == 's')) {
                    // bruta force verification
                    if (direction == 's') off = 0;
                    if (uea == null) fail(method2s(direction, method) + " SimpleEvent array response was null");
                    if (uea.size() != ea.size()) {
                        fail(method2s(direction, method) + " string SimpleEvent had wrong size " + uea.size()
                                + " (expected " + ea.size() + ")");
                    }
                    for (int i = 0; i < uea.size(); i++) {
                        SimpleEvent s1 = uea.get(i);
                        SimpleEvent s2 = earr[i + off];
                        if (!toString(s1).equals(toString(s2))) {
                            fail(method2s(direction, method) + " SimpleEvent array response"
                                    + " had wrong content (s1=" + s1 + " s2=" + s2 + " i=" + i + ")");
                        }
                    }
                }
            } else {
                throw new RuntimeException("unrecongized method " + method);
            }

            if (start > 0 && smokeTest) {
//                String resp = builder.serializeToString(handler.getLastResponse());
//                System.out.println(method2s(direction, method)+" response=\n"+resp+"---\n");
            }
        }
        if (start > 0) {
            long end = System.currentTimeMillis();
            long total = (end == start) ? 1 : (end - start);
            double seconds = (total / 1000.0);
            double invPerSecs = (double) N / seconds;
            double avgInvTimeInMs = (double) total / (double) N;
//            System.out.println("N=" + N + " avg invocation:" + avgInvTimeInMs + " [ms]" +
//                    "total:"+total+" [ms] "+
//                    " throughput:" + invPerSecs + " [invocations/second]" +
//                    " arraysSize=" + arrSize +
//                    " direction=" + direction +
//                    " method=" + method
//                    + " " + (new Date())
//            );
            td.printResult(avgInvTimeInMs / 1000.0, invPerSecs);
        }
    }