[zeromq-dev] DEALER <--> ROUTER <--> Double Read() is so slow. Please have a look at the codes.

crocket crockabiscuit at gmail.com
Mon Apr 15 08:02:41 CEST 2013


DEALER belongs to java, and ROUTER belongs to LabVIEW.

Below is the java code.

import java.nio.charset.Charset;
import java.util.Calendar;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.zeromq.ZContext;
import org.zeromq.ZMQ;

public class DSCTagTest {
    private static ZContext ctx;
    private static ZMQ.Socket tagReader;
    private static String address="tcp://localhost:23010";

    private Charset charset=Charset.forName("UTF-8");
    private int length=1000;

    @BeforeClass
    public static void setUp() {
        ctx=new ZContext();
        tagReader=ctx.createSocket(ZMQ.DEALER);
        tagReader.connect(address);
    }

    @AfterClass
    public static void tearDown() {
        ctx.close();
    }

    @Test
    public void readTagsFromDSC() throws InterruptedException {
        String baseAddr="\\kdckdc\\test\\V";
        String[] addrArray=new String[length];

        for(int i=0; i<length; ++i) {
            addrArray[i]=baseAddr + (i+1);
        }

        for(int i=0; i<30; ++i) {
            long start=Calendar.getInstance().getTimeInMillis();
            for(String addr : addrArray)
                tagReader.send(addr.getBytes(charset));

            for(int j=0; j<length; ++j) {
                Double value=Double.parseDouble(new
String(tagReader.recv(), charset));
            }
            long end=Calendar.getInstance().getTimeInMillis();

            System.out.println("Milliseconds taken to retrieve "+length+"
values from DSC : "+(end-start));
            System.out.println();

            Thread.sleep(1000);
        }
    }
}

The code that belongs to the LabVIEW code is attached as an image file
since LabVIEW is a graphical programming langauge.

[image: Inline image 1]

If I call Read Tag 1000 times directly without ZeroMQ, it finishes in
45~60ms.
If I call Read Tag from DSCTagTest via ZeroMQ, it takes 350~370ms to call
Read Tag 1000 times.

Why is it so slow?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130415/dd720816/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: labview-zmq-tagserver.png
Type: image/png
Size: 55853 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130415/dd720816/attachment.png>


More information about the zeromq-dev mailing list