private static Task run(GrpcWorker.GrpcWorkerClient client, int count) { for (int i = 0; i < 2; i++) { client.SetAsync(SetRequest($"{count}_{i}_{Guid.NewGuid()}", "hola mundo")); } return(Task.CompletedTask); }
public GrpcClient(GrpcWorker.GrpcWorkerClient client) { this.client = client; }
static async Task Main3(string[] args) { ThreadPool.SetMinThreads(500, 500); // await Task.Delay(25000); //var httpClientHandler = new HttpClientHandler(); //httpClientHandler.CheckCertificateRevocationList = false; ////httpClientHandler.PreAuthenticate = false; //httpClientHandler.SslProtocols = System.Security.Authentication.SslProtocols.Default; //httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Manual; //// Return `true` to allow certificates that are untrusted/invalid //httpClientHandler.ServerCertificateCustomValidationCallback = // HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; //var httpClient = new HttpClient(httpClientHandler); //var channel0 = GrpcChannel.ForAddress("https://172.25.182.182:443", // new GrpcChannelOptions { HttpClient = httpClient }); var channel0 = new Channel("localhost", 90, ChannelCredentials.Insecure); //var channel0 = GrpcChannel.ForAddress("localhost:90"); //var channel3 = GrpcChannel.ForAddress("https://172.25.164.211:80"); //var channel1 = GrpcChannel.ForAddress("https://172.25.164.211:80"); //var channel2 = GrpcChannel.ForAddress("https://172.25.164.211:80"); var client0 = new GrpcWorker.GrpcWorkerClient(channel0); //var client1 = new GrpcWorker.GrpcWorkerClient(channel0); //var client2 = new GrpcWorker.GrpcWorkerClient(channel0); //var client3 = new GrpcWorker.GrpcWorkerClient(channel0); // await run(client0); var sw = new Stopwatch(); // var valor2 = client0.Get(GetRequest("superkey")); //var response = client0.Set(SetRequest($"{Guid.NewGuid()}", "hola mundo")); //var response2 = client0.Set(SetRequest($"{Guid.NewGuid()}", "hola mundo")); //var response3 = client0.Set(SetRequest($"{Guid.NewGuid()}", "hola mundo")); //var valor = client0.Get(GetRequest("superkey")); //Console.WriteLine($"value is {valor.Results[0].Value?.Length}"); ////await Task.Delay(15000); // valor = client0.Get(GetRequest("superkey")); //Console.WriteLine($"now is value is {valor.Results[0].Value?.Length}"); ////var valueDeleted = client0.Delete(SetRequest("superkey", "")); ////Console.WriteLine($"Values has been deleted {valueDeleted.Results[0].Status}"); ////var valueNotDeleted = client0.Delete(SetRequest("superkey-notexist", "")); ////Console.WriteLine($"Values has been deleted {valueNotDeleted.Results.FirstOrDefault()?.Status ?? false}"); //valor = client0.Get(GetRequest("superkey")); //Console.WriteLine($"now is value is {valor.Results[0].Value?.Length}"); // Console.ReadLine(); //var s = valor.Results[0].Value.ToString(UTF8Encoding.UTF8); for (int i = 0; i < 10; i++) { sw.Restart(); //for (int ix = 0; ix < 10000; ix++) //{ // await client0.GetAsync(GetRequest("superkey")); // // await client0.SetAsync(SetRequest("superkey", "hola mundo")); //} var tasks = new[] { run(client0, i) }; await Task.WhenAll(tasks); Console.WriteLine($"Elapsed {sw.ElapsedMilliseconds} ratio {40000 / sw.Elapsed.TotalSeconds }"); } //valor = client0.Get(GetRequest("superkey")); //sw.Restart(); //for (int i = 0; i < 1000000; i++) //{ // valor = client0.Get(GetRequest("superkey")); //} //Console.WriteLine($"Elapsed {sw.ElapsedMilliseconds}"); ////if (Encoding.UTF8.GetString(valor.Results[0].Value.ToByteArray()) == "hola mundo") //// Console.WriteLine("funciono!"); Console.WriteLine("Hello World!"); Console.ReadKey(); }