public static List <PerformanceStat> GetPerformanceStats(int runNumber) { List <PerformanceStat> stats = new List <PerformanceStat>(); String connectionString = ConfigurationManager.ConnectionStrings["STUDENT"].ConnectionString;; using (OracleConnection con = new OracleConnection(connectionString)) { con.Open(); using (OracleCommand cmd = con.CreateCommand()) { cmd.CommandText = PERF_STATS_SQL; cmd.Parameters.Add(new OracleParameter(":run_number", runNumber)); using (OracleDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { PerformanceStat stat = new PerformanceStat(); stat.Name = reader.GetString(0); stat.Value = reader.GetDecimal(1); stat.Units = reader.GetString(2); stats.Add(stat); } } } } return(stats); }
// This method monitors and logs performance values like processor % and memory available on the instance public void getPerformance() { PerformanceCounter theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); PerformanceCounter theMemCounter = new PerformanceCounter("Memory", "Available MBytes"); theCPUCounter.NextValue(); Thread.Sleep(500); int currentCPU = (int)theCPUCounter.NextValue(); int currentMem = (int)theMemCounter.NextValue(); PerformanceStat newStat = new PerformanceStat(currentCPU, currentMem); TableOperation insertOperation = TableOperation.Insert(newStat); DBManager.getPerformanceTable().Execute(insertOperation); }
public float Evaluate(PerformanceStat stat) => Item?.Evaluate(stat) ?? Consumable.Evaluate(stat);