Exemple #1
0
        public static void Main(string[] args)
        {
            try {
                var iterate_over = Convert.ToInt32(args[1]);
                System.Diagnostics.Stopwatch sw = null;

                {
                    var client = new synapse_client(new type_factory(), args[0]);
                    client.subscribe("test.compare_xml_with_thrift_a.leon", new DateTime(1970, 1, 2), null, true);

                    var i = -1;
                    sw = System.Diagnostics.Stopwatch.StartNew();
                    for (var msg_wrapper = client.next(); msg_wrapper != null && ++i != iterate_over; msg_wrapper = client.next())
                    {
                        if (msg_wrapper.msg.get_type_id() != imaginary_bet_pool.type_id)
                        {
                            throw new Exception("unexpected message");
                        }
                    }
                    sw.Stop();
                    Console.WriteLine("thrift done. each message processed in: " + sw.ElapsedMilliseconds / (double)iterate_over + "(ms)");
                    client.close();
                }

                {
                    var client = new data_processors.xml.synapse_client(new data_processors.xml.type_factory(), args[0]);
                    client.subscribe("test.compare_xml_with_thrift_b.leon", new DateTime(1970, 1, 2), null, true);

                    sw = System.Diagnostics.Stopwatch.StartNew();
                    var i = -1;
                    for (var msg_wrapper = client.next(); msg_wrapper != null && ++i != iterate_over; msg_wrapper = client.next())
                    {
                        if (msg_wrapper.msg.get_type_id() != imaginary_bet_pool_xml.type_id)
                        {
                            throw new Exception("unexpected message");
                        }
                    }
                    sw.Stop();
                    Console.WriteLine("xml done. each message processed in: " + sw.ElapsedMilliseconds / (double)iterate_over + "(ms)");
                    client.close();
                }

                Console.WriteLine("bye bye");
            } catch (Exception e) {
                Console.WriteLine("oops " + e.Message);
            }
        }
Exemple #2
0
 public void run(SslPolicyErrors?use_ssl, string synapse_host, int synapse_port, string topic_name, string seed_from_topic_name, bool tcp_no_delay, int so_rcvbuf, int so_sndbuf)
 {
     client = new synapse_client <DataProcessors.Waypoints.waypoints>(use_ssl, synapse_host, synapse_port, tcp_no_delay, so_rcvbuf, so_sndbuf, 30, 100000);
     client.subscribe(new ReaderWriterLockSlim(), new DataProcessors.Contests4.type_factory(), seed_from_topic_name, 1);
     for (var msg_wrapper = client.next(5000); msg_wrapper != null; msg_wrapper = client.next(5000))
     {
         if (msg_wrapper.type_name == "Contests" && msg_wrapper.non_delta_seen == true)
         {
             msg = new DataProcessors.Contests4.Contests();
             msg.set_from((DataProcessors.Contests4.Contests)msg_wrapper.msg);
             msg.set_dataprovider("here comes some unicode \u76F4 and back to ascii :)");
             Console.Error.WriteLine("seeded message size " + msg_wrapper.wire_size);
             break;
         }
     }
     client.close();
     client = null;
     if (msg == null)
     {
         throw new System.Exception("could not seed");
     }
     worker = new Thread(new ThreadStart(() => {
         Console.Error.WriteLine("synapse_publisher running...");
         try
         {
             client = new data_processors.synapse_client <DataProcessors.Waypoints.waypoints>(use_ssl, synapse_host, synapse_port, tcp_no_delay, so_rcvbuf, so_sndbuf, 30, 100000);
             for (uint i = 1; i != 10001 + 1; ++i)
             {
                 var p = new snd_ping();
                 p.published_timestamp = i;
                 p.local_timestamp     = DateTime.UtcNow;
                 p.msg_size            = (ulong)client.publish(topic_name, msg, null, false, null, 0, i);
                 stats.Enqueue(p);
             }
         } catch {
             error = true;
             Console.Error.WriteLine("synapse_publisher exception");
         } finally {
             if (client != null)
             {
                 client.close();
             }
         }
     }));
     worker.Start();
 }