DD.WellWorkover.Cloud/ConsoleApp1/Program.cs

91 lines
3.4 KiB
C#
Raw Normal View History

2022-06-15 14:57:37 +05:00
using AsbCloudInfrastructure.EfCache;
2022-05-05 10:06:15 +05:00
using System;
2022-04-22 17:17:38 +05:00
using System.Linq;
2022-05-31 16:38:04 +05:00
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp1
{
2022-06-15 14:57:37 +05:00
class Program
2021-10-03 20:08:17 +05:00
{
2022-06-01 12:18:10 +05:00
// use ServiceFactory to make services
2021-07-28 09:47:13 +05:00
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);
2022-05-31 16:38:04 +05:00
Console.WriteLine("hit keyboard to start");
Console.ReadLine();
2022-03-17 16:56:13 +05:00
2022-05-31 16:38:04 +05:00
for (int i = 0; i < 24; i++)
2022-05-06 16:35:16 +05:00
{
2022-06-15 14:57:37 +05:00
var t = new Thread(_ =>
{
2022-06-01 15:59:02 +05:00
for (int j = 0; j < 32; j++)
//Task.Run(GetDataAsync).Wait();
GetData();
2022-05-31 16:38:04 +05:00
});
t.Start();
}
Console.WriteLine("End of Test");
Console.ReadLine();
2021-10-06 16:30:46 +05:00
}
2022-05-31 16:38:04 +05:00
static TimeSpan obso = TimeSpan.FromSeconds(5);
2022-06-01 15:59:02 +05:00
static (long, long) GetData()
2022-05-31 16:38:04 +05:00
{
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)
2022-06-01 15:59:02 +05:00
.FromCache("tds", obso, r => new { r.Pressure, r.HookWeight })
2022-05-31 16:38:04 +05:00
.ToList();
sw.Stop();
2022-06-01 12:18:10 +05:00
Console.WriteLine($"{DateTime.Now}\tth: {Thread.CurrentThread.ManagedThreadId}\ttime {sw.ElapsedMilliseconds}\tcount {cs.Count}");
2022-05-31 16:38:04 +05:00
GC.Collect();
2022-06-01 12:18:10 +05:00
Thread.Sleep(10);
2022-05-31 16:38:04 +05:00
return (cs.Count, sw.ElapsedMilliseconds);
}
2022-06-01 15:59:02 +05:00
static async Task<(long, long)> GetDataAsync()
2022-05-31 16:38:04 +05:00
{
using var db = ServiceFactory.MakeContext();
var sw = System.Diagnostics.Stopwatch.StartNew();
2022-06-01 15:59:02 +05:00
var cs = (await db.TelemetryDataSaub
2022-05-31 16:38:04 +05:00
.Where(t => t.IdTelemetry == 135)
.OrderBy(t => t.DateTime)
.Take(100_000)
2022-06-15 14:57:37 +05:00
.FromCacheDictionaryAsync("tds", obso, r => (r.IdTelemetry, r.DateTime), r => new { r.Pressure, r.HookWeight }))
2022-05-31 16:38:04 +05:00
.ToList();
sw.Stop();
2022-06-01 12:18:10 +05:00
Console.WriteLine($"{DateTime.Now}\tth: {Thread.CurrentThread.ManagedThreadId}\ttime {sw.ElapsedMilliseconds}\tcount {cs.Count}");
2022-05-31 16:38:04 +05:00
GC.Collect();
2022-06-01 12:18:10 +05:00
Thread.Sleep(10);
2022-05-31 16:38:04 +05:00
return (cs.Count, sw.ElapsedMilliseconds);
}
}
}