C
Join ServerC#
help
Trying to compare grpc to minimal api performence- minimal much faster, Logic probably rotten
KKosta11/22/2022
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:
And this was twice as fast , 3 million records in a minute then i figured out im testing it wrong,
However how do i use a client and what methode i need to invoke in the foreach?
How do i procced? obviously im doing smth/multiple things wrong.
If i try to do smth like this
I get a "does not contain extension defenition for getasyncenumarator
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 im testing it wrong,
However how do i use a client and what methode 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 im 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 defenition for getasyncenumarator
KKosta11/22/2022
Nobody got any idea guys? 😄
AAntonC11/22/2022
foreach (var line in await client.GetAsync(""))
maybeKKosta11/22/2022
Nop , same error ""does not contain extension defenition for getasyncenumarat"
AAntonC11/22/2022
remove
await
before foreachAAntonC11/22/2022
that one work with
IAsyncEnumerable
AAntonC11/22/2022
while you just get a single message supposedly