public void UpdateLviCache() { m_lviCache.Clear(); for (int i = 0; i < m_logViews.Count; i++) { LogView logView = m_logViews[i]; ListViewItem lvi = new ListViewItem(logView.m_name); lvi.ToolTipText = logView.m_name; if (logView.m_valueStats.ContainsKey(m_path)) { string formatString = logView.m_baseLogData.ItemMetaData[m_path].m_type == EItemType.Int ? "{0:n0}" : "{0:n2}"; ValueStats valueStats = logView.m_valueStats[m_path]; lvi.SubItems.Add(string.Format("{0:n0}", valueStats.m_numFrames)); lvi.SubItems.Add(string.Format(formatString, valueStats.m_numFrames == 0 ? 0 : valueStats.m_min)); lvi.SubItems.Add(string.Format(formatString, valueStats.m_numFrames == 0 ? 0 : valueStats.m_max)); lvi.SubItems.Add(string.Format(formatString, valueStats.m_avg)); } else { lvi.SubItems.Add("-"); lvi.SubItems.Add("-"); lvi.SubItems.Add("-"); lvi.SubItems.Add("-"); } m_lviCache.Add(lvi); } }
static void CalcSingleValueStat(ValueStats valueStats, int path, int fromIdx, int toIdx, GetValuesFromIndex valuesFromIdx) { for (int i = fromIdx; i <= toIdx; i++) { IReadOnlyFRVs values = valuesFromIdx(i); if (values.ContainsPath(path)) { valueStats.Update(values[path]); } } }
void CalculateValueStats(int fromIdx, int toIdx, IEnumerable <string> restrictToViewPaths) { int numTasks = 32; int numValueStats = m_valueStats.Count; int segmentSize = (numValueStats / numTasks) + 1; MTCounter counter = new MTCounter(numValueStats); GetValuesFromIndex perViewVFI = i => m_baseViewFRs[i].Values; GetValuesFromIndex perLogVFI = i => m_baseLogData.FrameRecords[i].Values; for (int i = 0; i < numTasks; ++i) { int start = i * segmentSize; int end = Math.Min(start + segmentSize, numValueStats); if (start >= end) { break; } ThreadPool.QueueUserWorkItem((o) => { for (int j = start; j < end; ++j) { string path = m_valueStats.Keys[j]; if (restrictToViewPaths != null && !restrictToViewPaths.Contains(path)) { continue; } ValueStats valueStats = m_valueStats.Values[j]; IReadOnlyFRPC paths = valueStats.m_bValueIsPerLogView ? m_viewPaths : m_dataPaths; GetValuesFromIndex valuesFromIdx = valueStats.m_bValueIsPerLogView ? perViewVFI : perLogVFI; CalcSingleValueStat(valueStats, paths.GetIndexFromPath(path), fromIdx, toIdx, valuesFromIdx); } counter.Increment(end - start); } ); } counter.WaitUntilMax(); }
public void AddValueStats(string path, bool bValueIsPerLogView) { m_valueStats[path] = new ValueStats(bValueIsPerLogView); }