2022-05-31 12:30:03 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
|
|
|
|
using AsbCloudDb.Model;
|
2022-05-31 16:38:04 +05:00
|
|
|
|
using AsbCloudInfrastructure.Services.Cache;
|
2022-05-06 10:58:52 +05:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2022-05-05 10:06:15 +05:00
|
|
|
|
using System;
|
2022-05-31 16:38:04 +05:00
|
|
|
|
using System.Collections.Generic;
|
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;
|
2021-10-26 17:22:32 +05:00
|
|
|
|
|
|
|
|
|
namespace ConsoleApp1
|
2021-04-02 17:28:07 +05:00
|
|
|
|
{
|
2022-05-31 16:38:04 +05:00
|
|
|
|
|
2021-04-02 17:28:07 +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*/)
|
2021-11-17 10:52:03 +05:00
|
|
|
|
{
|
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-05-31 16:38:04 +05:00
|
|
|
|
var t = new Thread(_ => {
|
|
|
|
|
for (int j = 0; j < 64; j++)
|
2022-06-01 12:18:10 +05:00
|
|
|
|
Task.Run(GetClastersAsync).Wait();
|
|
|
|
|
//GetClasters();
|
2022-05-31 16:38:04 +05:00
|
|
|
|
});
|
|
|
|
|
t.Start();
|
|
|
|
|
}
|
2021-12-02 15:36:51 +05:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
static (long, long) GetClasters()
|
|
|
|
|
{
|
|
|
|
|
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 12:18:10 +05:00
|
|
|
|
.FromCache("tds", obso)
|
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}\trequests {EfCacheL2rev4.RequestsToDb}\ttime {sw.ElapsedMilliseconds}\tcount {cs.Count}");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static async Task<(long, long)> GetClastersAsync()
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
.FromCacheAsync("tds", obso, r => (r.IdTelemetry, r.DateTime)))
|
|
|
|
|
.ToList();
|
|
|
|
|
sw.Stop();
|
2022-06-01 12:18:10 +05:00
|
|
|
|
//Console.WriteLine($"{DateTime.Now}\tth: {Thread.CurrentThread.ManagedThreadId}\trequests {EfCacheL2rev4.RequestsToDb}\ttime {sw.ElapsedMilliseconds}\tcount {cs.Count}");
|
|
|
|
|
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);
|
|
|
|
|
}
|
2021-04-02 17:28:07 +05:00
|
|
|
|
}
|
|
|
|
|
}
|