So i got this grpc client that streams data from a csv to a console and just prints it, in 1 minute it can do about 1.5mil records. On the other hand i got this minimal api, Now here begins the problem Im guessing I need to use httpclient to make the call inorder to compare? Because before i had this:
var client = new HttpClient();
await foreach (var line in MakeHttpCall())
{
Console.WriteLine(line);
}
And this was twice as fast , 3 million records in a minute then I figured out I'm testing it wrong, However how do i use a client and what method I need to invoke in the foreach?
async IAsyncEnumerable<string> MakeHttpCall()
{
var watch = System.Diagnostics.Stopwatch.StartNew();
int Count = 0;
using (var reader = new StreamReader(@"C:\Users\kosta\source\repos\gRPCDemoUsingNET6\gRPCDemoUsingNET6\Data\sales_records.csv"))
{
while (watch.Elapsed < TimeSpan.FromSeconds(60) && !reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(';');
yield return line;
Count++;
}
}
watch.Stop();
Console.WriteLine($"Stream ended: Total Records:{Count.ToString()} in {watch.Elapsed.TotalMinutes} minutes and {watch.Elapsed.TotalSeconds} seconds.");
}
How do I procced? Obviously I'm doing smth/multiple things wrong. If i try to do smth like this
await foreach (var line in client.GetAsync(""))
I get a "does not contain extension definition for getasyncenumarator