From d45145b8a568aba62d8bf9593706e5314dfe8489 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Mon, 27 Jun 2022 10:28:27 +0500 Subject: [PATCH] OperationDetectionBackgroundService remove statistic for optimization. --- .../OperationDetectionBackgroundService.cs | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/AsbCloudInfrastructure/Services/DetectOperations/OperationDetectionBackgroundService.cs b/AsbCloudInfrastructure/Services/DetectOperations/OperationDetectionBackgroundService.cs index 16e414ae..ead356ca 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/OperationDetectionBackgroundService.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/OperationDetectionBackgroundService.cs @@ -132,24 +132,13 @@ namespace AsbCloudInfrastructure.Services.DetectOperations var startDate = begin; var detectedOperations = new List(8); - var dbRequests_ = 0; - var dbTime_ = 0d; - var sw_ = new Stopwatch(); - var otherTime_ = 0d; - while (true) { - sw_.Restart(); var data = await query .Where(d => d.DateTime > startDate) .Take(take) .ToArrayAsync(token); - sw_.Stop(); - dbTime_ += sw_.ElapsedMilliseconds; - dbRequests_++; - sw_.Restart(); - if (data.Length < minFragmentLength) break; @@ -182,16 +171,9 @@ namespace AsbCloudInfrastructure.Services.DetectOperations skip += minStepLength; } - sw_.Stop(); - otherTime_ += sw_.ElapsedMilliseconds; - if (!isDetected) { - if (data.Length < take) - break; - - var lastPartDate = data.Last().DateTime; - startDate = startDate + (0.75 * (lastPartDate - startDate)); + startDate = startDate.AddSeconds(0.95 * take); } }