Merge tag 'AddAdvLog03' into develop
Update log: indicazione ora inizio + dimensione batch...
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
namespace Eqn.Sender
|
||||
{
|
||||
public class BStatData
|
||||
{
|
||||
public DateTime DtCreated { get; set; } = DateTime.Now;
|
||||
public int Size { get; set; } = 0;
|
||||
public double TimeSec { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,10 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
|
||||
namespace Eqn.Sender.Controllers
|
||||
@@ -172,7 +174,7 @@ namespace Eqn.Sender.Controllers
|
||||
int numErr = 0;
|
||||
int numResp = 0;
|
||||
// preparo statistiche invio
|
||||
ConcurrentBag<double> elapsedList = new ConcurrentBag<double>();
|
||||
ConcurrentBag<BStatData> elapsedTime = new ConcurrentBag<BStatData>();
|
||||
// preparare vera lista invio (multi messaggio)
|
||||
List<MulticastMessage> messageList = new List<MulticastMessage>();
|
||||
MulticastMessage newMessage = new MulticastMessage();
|
||||
@@ -242,11 +244,14 @@ namespace Eqn.Sender.Controllers
|
||||
await Parallel.ForEachAsync(messageList, async (message, token) =>
|
||||
{
|
||||
Stopwatch lsw = new Stopwatch();
|
||||
var currData = new BStatData(0, 0);
|
||||
lsw.Start();
|
||||
var resp = await fbService.DoSendMessage(message, dryRun);
|
||||
listBResp.Add(resp);
|
||||
lsw.Stop();
|
||||
elapsedList.Add(lsw.Elapsed.TotalSeconds);
|
||||
currData.Size = message.Tokens.Count;
|
||||
currData.TimeSec = lsw.Elapsed.TotalSeconds;
|
||||
elapsedTime.Add(currData);
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -254,11 +259,14 @@ namespace Eqn.Sender.Controllers
|
||||
foreach (var item in messageList)
|
||||
{
|
||||
Stopwatch lsw = new Stopwatch();
|
||||
var currData = new BStatData(0,0);
|
||||
lsw.Start();
|
||||
var resp = await fbService.DoSendMessage(item, dryRun);
|
||||
listBResp.Add(resp);
|
||||
lsw.Stop();
|
||||
elapsedList.Add(lsw.Elapsed.TotalSeconds);
|
||||
currData.Size = item.Tokens.Count;
|
||||
currData.TimeSec = lsw.Elapsed.TotalSeconds;
|
||||
elapsedTime.Add(currData);
|
||||
}
|
||||
}
|
||||
sw.Stop();
|
||||
@@ -280,21 +288,21 @@ namespace Eqn.Sender.Controllers
|
||||
// se durata > 5sec --> loggo!
|
||||
if (sw.Elapsed.TotalSeconds > 5)
|
||||
{
|
||||
int numSend = elapsedList.Count;
|
||||
int numSend = elapsedTime.Count;
|
||||
string logVal = $"Warnng soglia, durata: {sw.Elapsed.TotalSeconds:N3} sec | chiamate: {numCall} | batch: {numSend}";
|
||||
_logger.LogWarning(logVal);
|
||||
// scrivo tutte le righe
|
||||
int idx = 1;
|
||||
foreach (var item in elapsedList)
|
||||
foreach (var item in elapsedTime)
|
||||
{
|
||||
_logger.LogWarning($"{idx:00}| {item:N3} sec");
|
||||
_logger.LogWarning($"{idx:00} | Start: {item.DtCreated:HH:mm:ss.fff} | bSize:{item.Size} | {item.TimeSec:N3} sec");
|
||||
idx++;
|
||||
}
|
||||
|
||||
//// calcolo numero esecuzioni
|
||||
//double minTime = elapsedList.OrderBy(x => x).FirstOrDefault();
|
||||
//double avgTime = numSend > 0 ? elapsedList.Sum(x => x) / numSend : 0;
|
||||
//double maxTime = elapsedList.OrderByDescending(x => x).FirstOrDefault();
|
||||
//double minTime = elapsedTime.OrderBy(x => x).FirstOrDefault();
|
||||
//double avgTime = numSend > 0 ? elapsedTime.Sum(x => x) / numSend : 0;
|
||||
//double maxTime = elapsedTime.OrderByDescending(x => x).FirstOrDefault();
|
||||
//string stats = $"Batch processati: {numSend} | minTime: {minTime:N3} | avgTime: {avgTime:N3} | maxTime: {maxTime:N3}";
|
||||
//_logger.LogWarning(stats);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user