コード例 #1
0
ファイル: cs_local_lat.cs プロジェクト: xinfang/zeromq1
    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;
    }
コード例 #2
0
ファイル: cs_remote_lat.cs プロジェクト: Vnaki/zeromq1
    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);
    }
コード例 #3
0
ファイル: cs_remote_lat.cs プロジェクト: xinfang/zeromq1
    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;
    }
コード例 #4
0
ファイル: cs_remote_thr.cs プロジェクト: Vnaki/zeromq1
    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);
    }
コード例 #5
0
ファイル: cs_local_thr.cs プロジェクト: xinfang/zeromq1
    static unsafe int Main(string [] args)
    {
        if (args.Length != 4)
        {
            Console.Out.WriteLine ("usage: cs_local_thr <hostname> " +
                "<queue-interface> <message-size> <message-count>\n");
            return 1;
        }

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

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

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

        //  Set up 0MQ wiring.
        w.CreateQueue ("Q", Zmq.SCOPE_GLOBAL, queueInterface,
            Zmq.NO_LIMIT, Zmq.NO_LIMIT, Zmq.NO_SWAP);

        byte[] message;
        int type;

        //  Receive the first message.
        w.Receive (out message, out type, true);
        Debug.Assert (message.Length == messageSize);

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

        //  Start receiving messages
        for (int i = 0; i < msgCount - 1; i++)
        {
            w.Receive (out message, out type, true);
            Debug.Assert (message.Length == messageSize);
        }

        //  Stop measuring the time.
        watch.Stop ();
        Int64 elapsedTime = watch.ElapsedTicks;

        //  Compute and print out the throughput.
        Int64 messageThroughput;
        Int64 megabitThroughput;

        //message_throughput = (Int64) (msg_count / time);
        messageThroughput = (Int64) (msgCount *Stopwatch.Frequency /
            elapsedTime);
        megabitThroughput = messageThroughput * messageSize * 8 /
            1000000;

        Console.Out.WriteLine ("Your average throughput is {0} [msg/s]",
            messageThroughput.ToString ());
        Console.Out.WriteLine ("Your average throughput is {0} [Mb/s]",
            megabitThroughput.ToString ());

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

        return 0;
    }
コード例 #6
0
ファイル: cs_local_lat.cs プロジェクト: Vnaki/zeromq1
    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);
    }
コード例 #7
0
    static unsafe int Main(string [] args)
    {
        if (args.Length != 4)
        {
            Console.Out.WriteLine("usage: cs_local_thr <hostname> " +
                                  "<queue-interface> <message-size> <message-count>\n");
            return(1);
        }

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

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

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

        //  Set up 0MQ wiring.
        w.CreateQueue("Q", Zmq.SCOPE_GLOBAL, queueInterface,
                      Zmq.NO_LIMIT, Zmq.NO_LIMIT, Zmq.NO_SWAP);

        byte[] message;
        int    type;

        //  Receive the first message.
        w.Receive(out message, out type, true);
        Debug.Assert(message.Length == messageSize);

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

        //  Start receiving messages
        for (int i = 0; i < msgCount - 1; i++)
        {
            w.Receive(out message, out type, true);
            Debug.Assert(message.Length == messageSize);
        }

        //  Stop measuring the time.
        watch.Stop();
        Int64 elapsedTime = watch.ElapsedTicks;

        //  Compute and print out the throughput.
        Int64 messageThroughput;
        Int64 megabitThroughput;

        //message_throughput = (Int64) (msg_count / time);
        messageThroughput = (Int64)(msgCount * Stopwatch.Frequency /
                                    elapsedTime);
        megabitThroughput = messageThroughput * messageSize * 8 /
                            1000000;

        Console.Out.WriteLine("Your average throughput is {0} [msg/s]",
                              messageThroughput.ToString());
        Console.Out.WriteLine("Your average throughput is {0} [Mb/s]",
                              megabitThroughput.ToString());

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

        return(0);
    }