@Test
    public void dispatcherPerformanceTest() throws InterruptedException {
        final int nMessages = 1000000;
        final CountDownLatch latch = new CountDownLatch(nMessages);
        ZContext ctx = new ZContext();
        ZDispatcher dispatcher = new ZDispatcher();

        ZMQ.Socket in = ctx.createSocket(ZMQ.ROUTER);
        in.bind("inproc://zmsg.test");

        ZMQ.Socket out = ctx.createSocket(ZMQ.DEALER);
        out.connect("inproc://zmsg.test");

        dispatcher.registerHandler(in, new ZDispatcher.ZMessageHandler() {
            @Override
            public void handleMessage(ZDispatcher.ZSender sender, ZMsg msg) {
                latch.countDown();
            }
        }, new ZDispatcher.ZSender());


        long start = System.currentTimeMillis();
        for (int i = 0; i < nMessages; i++) {
            ZMsg msg = new ZMsg();
            msg.addLast(UUID.randomUUID().toString());
            msg.send(out);
        }
        System.out.println(MessageFormat.format("performanceTest message sent:{0}", nMessages));
        latch.await();
        System.out.println(MessageFormat.format("performanceTest throughput:{0} messages/seconds", nMessages / ((System.currentTimeMillis() - start) / 1000)));

        dispatcher.shutdown();
        ctx.destroy();
    }