using AsbCloudInfrastructure.EfCache; using System; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { // use ServiceFactory to make services static void Main(/*string[] args*/) { System.Collections.Generic.List<(double, double)> data = new() { (22.52400016784668, 17715023.435277779) , (22.52400016784668, 17715023.435555555) , (22.52400016784668, 17715023.435833335) , (22.52400016784668, 17715023.436111111) , (22.547000885009766, 17715023.436388887) , (22.833000183105469, 17715023.436666667) , (23.063999176025391, 17715023.436944444) , (23.298999786376953, 17715023.437222224) , (23.5310001373291, 17715023.4375) , (23.763999938964844, 17715023.437777776) , (23.993999481201172, 17715023.438055556) , (24.229999542236328, 17715023.438333333) , (24.459999084472656, 17715023.438611113) , (24.694999694824219, 17715023.438888889) , (24.926000595092773, 17715023.439166665) , }; var il = new AsbCloudInfrastructure.Services.DetectOperations.InterpolationLine(data); Console.WriteLine("hit keyboard to start"); Console.ReadLine(); for (int i = 0; i < 24; i++) { var t = new Thread(_ => { for (int j = 0; j < 32; j++) //Task.Run(GetDataAsync).Wait(); GetData(); }); t.Start(); } Console.WriteLine("End of Test"); Console.ReadLine(); } static TimeSpan obso = TimeSpan.FromSeconds(5); static (long, long) GetData() { using var db = ServiceFactory.MakeContext(); var sw = System.Diagnostics.Stopwatch.StartNew(); var cs = db.TelemetryDataSaub .Where(t => t.IdTelemetry == 135) .OrderBy(t => t.DateTime) .Take(100_000) .FromCache("tds", obso, r => new { r.Pressure, r.HookWeight }) .ToList(); sw.Stop(); Console.WriteLine($"{DateTime.Now}\tth: {Thread.CurrentThread.ManagedThreadId}\ttime {sw.ElapsedMilliseconds}\tcount {cs.Count}"); GC.Collect(); Thread.Sleep(10); return (cs.Count, sw.ElapsedMilliseconds); } static async Task<(long, long)> GetDataAsync() { using var db = ServiceFactory.MakeContext(); var sw = System.Diagnostics.Stopwatch.StartNew(); var cs = (await db.TelemetryDataSaub .Where(t => t.IdTelemetry == 135) .OrderBy(t => t.DateTime) .Take(100_000) .FromCacheDictionaryAsync("tds", obso, r => (r.IdTelemetry, r.DateTime), r => new { r.Pressure, r.HookWeight })) .ToList(); sw.Stop(); Console.WriteLine($"{DateTime.Now}\tth: {Thread.CurrentThread.ManagedThreadId}\ttime {sw.ElapsedMilliseconds}\tcount {cs.Count}"); GC.Collect(); Thread.Sleep(10); return (cs.Count, sw.ElapsedMilliseconds); } } }