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); } }
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(); }
public static void Main(string[] args) { try { var iterate_over = Convert.ToInt32(args[2]); var total_runners = Convert.ToInt32(args[1]); ++total_runners; System.Diagnostics.Stopwatch sw = null; Random rnd = null; { rnd = new Random(); var client = new synapse_client(new type_factory(), args[0]); // Custom message creation sw = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i != iterate_over; ++i) { var bet_pool = new imaginary_bet_pool(); bet_pool.set_xid("11-06-2008;Hong+Kong;1;1208%3AHK;quartet;1;4.1;150;50;b"); bet_pool.set_sid("optionally set sid value:x12:1251:777"); if (bet_pool.get_description() == null) { bet_pool.set_description("sample description of a message for the betting pool(s)"); } // build some sample combos for (byte a = 1; a != total_runners; ++a) { for (byte b = 1; b != total_runners - 1; ++b) { for (byte c = 1; c != total_runners - 2; ++c) { for (byte d = 1; d != total_runners - 3; ++d) { bet_pool.set_combinations_element(new byte[] { a, b, c, d }, i * .01); } } } } bet_pool.set_When(client.timestamp_now()); client.publish("test.compare_xml_with_thrift_a.leon", bet_pool, false); } sw.Stop(); Console.WriteLine("thrift done. each message processed in: " + sw.ElapsedMilliseconds / (double)iterate_over + "(ms); message-rate: " + iterate_over / (sw.ElapsedMilliseconds * 0.001) + ", message size: " + client.stream.Length + ", participating runners: " + (total_runners - 1) + ", averaged over: " + iterate_over + " transactions"); client.close(); } // System.Threading.Thread.Sleep(10000); { rnd = new Random(); var client = new data_processors.xml.synapse_client(new data_processors.xml.type_factory(), args[0]); sw = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i != iterate_over; ++i) { var bet_pool = new imaginary_bet_pool_xml(); bet_pool.xid = "11-06-2008;Hong+Kong;1;1208%3AHK;quartet;1;4.1;150;50;b"; bet_pool.sid = "optionally set sid value:x12:1251:777"; bet_pool.description = "sample description of a message for the betting pool(s)"; bet_pool.combinations = new List <c>(); int blag = 0; // build some sample combos for (byte a = 1; a != total_runners; ++a) { for (byte b = 1; b != total_runners - 1; ++b) { for (byte c = 1; c != total_runners - 2; ++c) { for (byte d = 1; d != total_runners - 3; ++d) { var combo = new c(); //combo.r = a.ToString() + "," + b.ToString() + "," + c.ToString() + "," + d.ToString(); combo.r = ++blag; combo.p = (double)i * .01; bet_pool.combinations.Add(combo); } } } } bet_pool.When = client.timestamp_now(); client.publish("test.compare_xml_with_thrift_b.leon", bet_pool); } sw.Stop(); Console.WriteLine("xml done. each message processed in: " + sw.ElapsedMilliseconds / (double)iterate_over + "(ms); message-rate: " + iterate_over / (sw.ElapsedMilliseconds * 0.001) + ", message size: " + client.stream.Length + ", participating runners: " + (total_runners - 1) + ", averaged over: " + iterate_over + " transactions"); client.close(); } Console.WriteLine("bye bye"); } catch (Exception e) { Console.WriteLine("oops " + e.Message); } }