Exemplo n.º 1
0
    static unsafe int Main(string [] args)
    {
        if (args.Length != 3)
        {
            Console.Out.WriteLine ("usage: cs_local_lat <hostname> " +
                "<message-size> <roundtrip-count>\n");
            return 1;
        }

        String host = args [0];
        uint messageSize = Convert.ToUInt32 (args [1]);
        int roundtripCount = Convert.ToInt32 (args [2]);

        //  Print out the test parameters.
        Console.Out.WriteLine ("message size: " + messageSize + " [B]");
        Console.Out.WriteLine ("roundtrip count: " + roundtripCount);

        //  Create 0MQ Dnzmq class.
        Zmq w = new Zmq (host);

        //  Set up 0MQ wiring.
        int exchange = w.CreateExchange ("EL", Zmq.SCOPE_LOCAL, "",
            Zmq.STYLE_LOAD_BALANCING);
        w.CreateQueue ("QL", Zmq.SCOPE_LOCAL, "",
            Zmq.NO_LIMIT, Zmq.NO_LIMIT, Zmq.NO_SWAP);
        w.Bind ("EL", "QG", null, null);
        w.Bind ("EG", "QL", null, null);

        //  Create a message to send.
        byte[] outMessage = new byte[messageSize];

        //  Start measuring the time.
        System.Diagnostics.Stopwatch watch;
        watch = new Stopwatch ();
        watch.Start ();

        byte[] inMessage;
        int type;
        //  Start sending messages.
        for (int i = 0; i < roundtripCount; i++)
        {
            w.Send (exchange, outMessage, true);
            w.Receive (out inMessage, out type, true);
            Debug.Assert (inMessage.Length == messageSize);
        }
        //  Stop measuring the time.
        watch.Stop ();
        Int64 elapsedTime = watch.ElapsedTicks;

        //  Compute and print out the latency.
        double latency = (double) (elapsedTime) / roundtripCount / 2 *
            1000000 / Stopwatch.Frequency;
        Console.Out.WriteLine ("Your average latency is {0} [us]",
            latency.ToString ("f2"));

        System.Threading.Thread.Sleep (5000);
        w.Destroy ();

        return 0;
    }
Exemplo n.º 2
0
    static unsafe int Main(string [] args)
    {
        if (args.Length != 5)
        {
            Console.Out.WriteLine("usage: cs_remote_lat <hostname> " +
                                  "<exchange_interface> <queue_interface> " +
                                  "<message-size> <roundtrip-count>\n");
            return(1);
        }

        String host = args [0];
        String exchangeInterface = args[1];
        String queueInterface    = args [2];
        uint   messageSize       = Convert.ToUInt32(args [3]);
        int    roundtripCount    = Convert.ToInt32(args [4]);

        //  Create 0MQ Dnzmq class.
        Zmq w = new Zmq(host);

        //  Set up 0MQ wiring.
        int exchange = w.CreateExchange("EG", Zmq.SCOPE_GLOBAL,
                                        exchangeInterface, Zmq.STYLE_LOAD_BALANCING);

        w.CreateQueue("QG", Zmq.SCOPE_GLOBAL,
                      queueInterface, Zmq.NO_LIMIT, Zmq.NO_LIMIT, Zmq.NO_SWAP);
        byte[] message;
        int    type;

        //  Bounce the received messages.
        for (int i = 0; i < roundtripCount; i++)
        {
            w.Receive(out message, out type, true);
            Debug.Assert(message.Length == messageSize);
            w.Send(exchange, message, true);
        }

        System.Threading.Thread.Sleep(5000);
        w.Destroy();

        return(0);
    }
Exemplo n.º 3
0
    static unsafe int Main(string [] args)
    {
        if (args.Length != 5)
        {
            Console.Out.WriteLine ("usage: cs_remote_lat <hostname> " +
                "<exchange_interface> <queue_interface> " +
                "<message-size> <roundtrip-count>\n");
            return 1;
        }

        String host = args [0];
        String exchangeInterface = args[1];
        String queueInterface = args [2];
        uint messageSize = Convert.ToUInt32 (args [3]);
        int roundtripCount = Convert.ToInt32 (args [4]);

        //  Create 0MQ Dnzmq class.
        Zmq w = new Zmq (host);

        //  Set up 0MQ wiring.
        int exchange = w.CreateExchange ("EG", Zmq.SCOPE_GLOBAL,
            exchangeInterface, Zmq.STYLE_LOAD_BALANCING);
        w.CreateQueue ("QG", Zmq.SCOPE_GLOBAL,
            queueInterface, Zmq.NO_LIMIT, Zmq.NO_LIMIT, Zmq.NO_SWAP);
        byte[] message;
        int type;

        //  Bounce the received messages.
        for (int i = 0; i < roundtripCount; i++)
        {
            w.Receive (out message, out type, true);
            Debug.Assert (message.Length == messageSize);
            w.Send (exchange, message, true);
        }

        System.Threading.Thread.Sleep (5000);
        w.Destroy ();

        return 0;
    }
Exemplo n.º 4
0
    static unsafe int Main(string [] args)
    {
        if (args.Length != 3)
        {
            Console.Out.WriteLine("usage: cs_remote_thr <hostname> " +
                                  "<message-size> <message-count>\n");
            return(1);
        }

        String host        = args[0];
        uint   messageSize = Convert.ToUInt32(args[1]);
        int    msgCount    = Convert.ToInt32(args[2]);

        //  Create 0MQ Dnzmq class
        Zmq w = new Zmq(host);

        //  Set up 0MQ wiring.
        int exchange = w.CreateExchange("E", Zmq.SCOPE_LOCAL, "",
                                        Zmq.STYLE_LOAD_BALANCING);

        w.Bind("E", "Q", null, null);

        //  Create a message to send.
        byte[] message = new byte[messageSize];

        //  Start sending messages.
        for (int i = 0; i < msgCount; i++)
        {
            w.Send(exchange, message, true);
        }

        System.Threading.Thread.Sleep(10000);

        w.Destroy();
        return(0);
    }
Exemplo n.º 5
0
    static unsafe int Main(string [] args)
    {
        if (args.Length != 3)
        {
            Console.Out.WriteLine("usage: cs_local_lat <hostname> " +
                                  "<message-size> <roundtrip-count>\n");
            return(1);
        }

        String host           = args [0];
        uint   messageSize    = Convert.ToUInt32(args [1]);
        int    roundtripCount = Convert.ToInt32(args [2]);

        //  Print out the test parameters.
        Console.Out.WriteLine("message size: " + messageSize + " [B]");
        Console.Out.WriteLine("roundtrip count: " + roundtripCount);

        //  Create 0MQ Dnzmq class.
        Zmq w = new Zmq(host);

        //  Set up 0MQ wiring.
        int exchange = w.CreateExchange("EL", Zmq.SCOPE_LOCAL, "",
                                        Zmq.STYLE_LOAD_BALANCING);

        w.CreateQueue("QL", Zmq.SCOPE_LOCAL, "",
                      Zmq.NO_LIMIT, Zmq.NO_LIMIT, Zmq.NO_SWAP);
        w.Bind("EL", "QG", null, null);
        w.Bind("EG", "QL", null, null);

        //  Create a message to send.
        byte[] outMessage = new byte[messageSize];

        //  Start measuring the time.
        System.Diagnostics.Stopwatch watch;
        watch = new Stopwatch();
        watch.Start();


        byte[] inMessage;
        int    type;

        //  Start sending messages.
        for (int i = 0; i < roundtripCount; i++)
        {
            w.Send(exchange, outMessage, true);
            w.Receive(out inMessage, out type, true);
            Debug.Assert(inMessage.Length == messageSize);
        }
        //  Stop measuring the time.
        watch.Stop();
        Int64 elapsedTime = watch.ElapsedTicks;

        //  Compute and print out the latency.
        double latency = (double)(elapsedTime) / roundtripCount / 2 *
                         1000000 / Stopwatch.Frequency;

        Console.Out.WriteLine("Your average latency is {0} [us]",
                              latency.ToString("f2"));

        System.Threading.Thread.Sleep(5000);
        w.Destroy();

        return(0);
    }