62 lines
2.1 KiB
C#
62 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace WebDoorCreator.SDK
|
|
{
|
|
public class ProcStats
|
|
{
|
|
private static ConcurrentDictionary<string, long> Counter = new ConcurrentDictionary<string, long>();
|
|
private static ConcurrentDictionary<string, long> Timers = new ConcurrentDictionary<string, long>();
|
|
internal static void UpdateStat(string functionName, long timer)
|
|
{
|
|
if (!Timers.ContainsKey(functionName))
|
|
Timers.TryAdd(functionName, timer);
|
|
else
|
|
Timers[functionName] += timer;
|
|
|
|
if (!Counter.ContainsKey(functionName))
|
|
Counter.TryAdd(functionName, 1);
|
|
else
|
|
Counter[functionName]++;
|
|
}
|
|
|
|
internal volatile static Dictionary<string, string> RunningThreadStatus = new Dictionary<string, string>();
|
|
|
|
public static ConcurrentQueue<(string, long, long)> RecordList = new ConcurrentQueue<(string, long, long)>();
|
|
public static ConcurrentDictionary<int, CumSumData> ExeCumSum = new ConcurrentDictionary<int, CumSumData>();
|
|
|
|
public static bool RecordData(int numThread , long exeTime, long othTime)
|
|
{
|
|
bool fatto = false;
|
|
if (ExeCumSum.ContainsKey(numThread))
|
|
{
|
|
ExeCumSum[numThread].NumRec++;
|
|
ExeCumSum[numThread].ExeTime += exeTime;
|
|
ExeCumSum[numThread].OthTime += othTime;
|
|
}
|
|
else
|
|
{
|
|
ExeCumSum.TryAdd(numThread, new CumSumData(1, exeTime, othTime));
|
|
}
|
|
return fatto;
|
|
}
|
|
|
|
public class CumSumData
|
|
{
|
|
public CumSumData(long nrec, long eTime, long oTime)
|
|
{
|
|
NumRec = nrec;
|
|
ExeTime = eTime;
|
|
OthTime = oTime;
|
|
}
|
|
public long NumRec { get; set; } = 0;
|
|
public long ExeTime { get; set; } = 0;
|
|
public long OthTime { get; set; } = 0;
|
|
}
|
|
}
|
|
}
|