Beispiel #1
0
 static void Threading()
 {
     var c = new ProtoConnection ();
     var callbacks = new CallbackMonitor ();
     Random random = new Random();
     new Thread (() => {
         while (true) {
             c.Callback (callbacks, c.CreateBuilder ()
                 .SetFiles (ListResponse.CreateBuilder ().Build ())
                 .Build ());
             Thread.Sleep(random.Next(0, 10));
         }
     }).Start ();
     new Thread (() => {
         while (true) {
             c.Write<ListResponse> (null);
             Thread.Sleep(random.Next(0, 10));
         }
     }).Start ();
     new Thread (() => {
         while (true) {
             c.Callback (callbacks, c.CreateBuilder ()
                 .SetChunk(FileChunk.CreateBuilder().Build())
                 .Build ());
             Thread.Sleep(random.Next(0, 10));
         }
     }).Start ();
     new Thread (() => {
         while (true) {
             c.Write<FileChunk> (null);
             Thread.Sleep(random.Next(0, 10));
         }
     }).Start ();
 }
Beispiel #2
0
 static void Benchmark()
 {
     ProtoConnection c = new ProtoConnection (new IPEndPoint (IPAddress.Parse ("127.0.0.1"), 9001));
     c.Connect (true);
     for (int i = 0; i < 100000; i++) {
         ListResponse fl = c.Write<ListResponse> (c.CreateBuilder ()
             .SetListRequest (ListRequest.CreateBuilder ()
                 .SetPath ("/")
                 .Build ())
             .Build ());
         logger.Log (i % 1000 == 0 ? NLog.LogLevel.Info : NLog.LogLevel.Debug, fl.GetFile (0));
     }
 }