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 Counter = new ConcurrentDictionary(); private static ConcurrentDictionary Timers = new ConcurrentDictionary(); 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 RunningThreadStatus = new Dictionary(); public static ConcurrentQueue<(string, long, long)> RecordList = new ConcurrentQueue<(string, long, long)>(); public static ConcurrentDictionary ExeCumSum = new ConcurrentDictionary(); 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; } } }