private void SaveStats() { string stamp = this.getStamp(); if (this.hshChunks[(object)stamp] != null) { return; } this.milisec_cpu_slowest = 0.0; this.milisec_cpu_work -= this.milisec_sql_work; this.ProcessList(); CpuData cpuData = new CpuData(); cpuData.milisec_idle_work = this.milisec_idle_work; cpuData.milisec_cpu_work = this.milisec_cpu_work; cpuData.milisec_cpu_slowest = this.milisec_cpu_slowest; cpuData.milisec_avg_sql = this.milisec_sql_work + this.milisec_cpu_work == 0.0 ? 0.0 : 100.0 * this.milisec_sql_work / (this.milisec_sql_work + this.milisec_cpu_work); cpuData.totSqlCalls = this.totSqlCalls; cpuData.milisec_avg_idle = 100.0; if (this.milisec_idle_work + this.milisec_cpu_work != 0.0) { cpuData.milisec_avg_idle = 100.0 * this.milisec_idle_work / (this.milisec_idle_work + this.milisec_cpu_work); } this.hshChunks[(object)stamp] = (object)cpuData; this.lstStamps.Add((object)stamp); ArrayList arrayList = new ArrayList(); this.getLatestCpuLoads(1, ref arrayList); this.AppendDisk("cpu_stats.log", ref arrayList); this.milisec_sql_work = 0.0; }
public void getLatestCpuLoads(int count_last, ref ArrayList results) { for (int count = this.lstStamps.Count; count > 0; --count) { CpuData hshChunk = this.hshChunks[(object)(this.lstStamps[count - 1] as string)] as CpuData; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(this.lstStamps[count - 1] as string); stringBuilder.Append(" >> Idle ("); stringBuilder.Append(string.Format("{0:n}", (object)hshChunk.milisec_avg_idle)); stringBuilder.Append("%) Slowest Request ("); stringBuilder.Append(string.Format("{0:n}", (object)hshChunk.milisec_cpu_slowest)); stringBuilder.Append(" ms) DataBase ("); stringBuilder.Append(string.Format("{0:n}", (object)hshChunk.milisec_avg_sql)); stringBuilder.Append("%) Calls ("); stringBuilder.Append(hshChunk.totSqlCalls); stringBuilder.Append(")"); results.Add((object)stringBuilder.ToString()); if (count_last > 0 && --count_last == 0) { break; } } }