private void CompareAndExport() { lock (this) { iIndex = 0; } for ( ; iIndex < iDataSets.Count;) { CSVDataSet set = iDataSets[iIndex]; iExcelExporter.Export(set); // Report progress to any observers if (eObserver != null) { eObserver(TEvent.EExportingProgress); } lock (this) { ++iIndex; } } }
public CSVWorkerTwoDataSetComparator(CSVDataSet aCol1, CSVDataSet aCol2, string aOutputFileName) { // Make copies because we actually dequeue items from the list as we processed them // and we must not alter the originals or else we'll break the subsequent comparison(s) iCol1 = new CSVDataSet(aCol1); iCol2 = new CSVDataSet(aCol2); iExcelExporter = new CSVExcelExporterTwoDataSets(aOutputFileName, aCol1.FileName, aCol2.FileName); }
public CSVDataSet(CSVDataSet aCopy) { iOriginalFileName = aCopy.OriginalFileName; iLineNumber = aCopy.LineNumber; foreach (KeyValuePair <string, CSVThread> kvp in aCopy.iEntries) { iEntries.Add(kvp.Key, kvp.Value); } }
public void Export(CSVDataSet aSet) { int count = aSet.Count; for (int i = 0; i < count; i++) { CSVThread thread = aSet[i]; // find row if (iThreadMap.ContainsKey(thread.ThreadId)) { TThreadMapEntry entry = iThreadMap[thread.ThreadId]; Utils.SetValue(entry.iRowIndex, iColumnCounter, iSheetChunkSize, thread.SizeCurrent.ToString()); Utils.SetValue(entry.iRowIndex, iColumnCounter, iSheetAlloc, thread.AllocSpaceTotal.ToString()); Utils.SetValue(entry.iRowIndex, iColumnCounter, iSheetFree, thread.FreeSpaceTotal.ToString()); // Update stats ++entry.iNumberOfMatchingDataSets; // Min & max for each type entry.iRangeChunk.UpdateMin(thread.SizeCurrent); entry.iRangeChunk.UpdateMax(thread.SizeCurrent); entry.iRangeAlloc.UpdateMin(thread.AllocSpaceTotal); entry.iRangeAlloc.UpdateMax(thread.AllocSpaceTotal); entry.iRangeFree.UpdateMin(thread.FreeSpaceTotal); entry.iRangeFree.UpdateMax(thread.FreeSpaceTotal); // Delta for each type long deltaChunk = entry.iLastChunk > 0 ? (thread.SizeCurrent - entry.iLastChunk) : 0; long deltaAlloc = entry.iLastAlloc > 0 ? (thread.AllocSpaceTotal - entry.iLastAlloc) : 0; long deltaFree = entry.iLastFree > 0 ? (thread.FreeSpaceTotal - entry.iLastFree) : 0; entry.iDeltaChunk += deltaChunk; entry.iDeltaAlloc += deltaAlloc; entry.iDeltaFree += deltaFree; // Net effect entry.iNetEffectChunk += CSVExcelExporterAllDataSets.NetEffectForDelta(deltaChunk); entry.iNetEffectAlloc += CSVExcelExporterAllDataSets.NetEffectForDelta(deltaAlloc); entry.iNetEffectFree += CSVExcelExporterAllDataSets.NetEffectForDelta(deltaFree); // Update last values entry.iLastChunk = thread.SizeCurrent; entry.iLastAlloc = thread.AllocSpaceTotal; entry.iLastFree = thread.FreeSpaceTotal; } else { throw new Exception("Cannot find thread entry for thread named: " + thread.ThreadName); } } ++iColumnCounter; }
internal void RemoveEmptyDataSets() { for (int i = iDataSets.Count - 1; i >= 0; i--) { CSVDataSet set = iDataSets[i]; if (set.Count == 0) { iDataSets.RemoveAt(i); } } }
internal bool Contains(CSVDataSet aDataSet) { Predicate <CSVDataSet> findByFileAndLine = delegate(CSVDataSet setToCheck) { return((setToCheck.FileName == aDataSet.FileName) && (setToCheck.LineNumber == aDataSet.LineNumber)); }; bool ret = iDataSets.Exists(findByFileAndLine); return(ret); }
private void IdentifySharedHeaps() { // MemSpy should (and could) do this, at least eventually, but for now // we'll work this out on the PC if MemSpy supplied us with the chunk handles for // each thread. int count = iDataSets.Count; for (int i = 0; i < count; i++) { CSVDataSet dataSet = iDataSets[i]; dataSet.FindSharedHeaps(); } }
private void AddThreadsToList(CSVDataSet aSet, SortedDictionary <long, string> aList) { int count = aSet.Count; for (int i = count - 1; i >= 0; i--) { CSVThread master = aSet[i]; if (aList.ContainsKey(master.ThreadId) == false) { aList.Add(master.ThreadId, master.FullName); } } }
private SortedDictionary <long, string> IdentifyAllThreadNames() { // Get a list of unique thread ids and their full names SortedDictionary <long, string> list = new SortedDictionary <long, string>(); int count = iDataSets.Count; for (int i = 0; i < count; i++) { CSVDataSet set = iDataSets[i]; AddThreadsToList(set, list); } return(list); }
protected override void HandleFilteredLine(string aLine) { string originalLine = aLine; iCleaner.CleanLine(ref aLine); // Strip prefix if (CheckForKnownElement(ref aLine, KRDebugPrefixes)) { } // Main handler if (CheckForKnownElement(ref aLine, KMarkerEnd)) { // Finished an item - forced flush if (iCurrentDataSet != null) { iStorage.Add(iCurrentDataSet); } iCurrentDataSet = new CSVDataSet(base.FileName, base.LineNumber); iParser.CurrentDataSet = iCurrentDataSet; } else if (CheckForKnownElement(ref aLine, KMarkerStart)) { // Start of item - make a new entry iCurrentDataSet = new CSVDataSet(base.FileName, base.LineNumber); iParser.CurrentDataSet = iCurrentDataSet; } else { // Is it a valid line? CSVThread threadEntry = iParser.ParseLine(aLine); if (threadEntry != null) { if (iCurrentDataSet != null) { iCurrentDataSet.Add(threadEntry); } } } }
private CSVThread FindAppropriateSecondary(CSVThread aMaster, CSVDataSet aSecondaryCol) { System.Diagnostics.Debug.Assert(aMaster.FullName != string.Empty); // We must try to find the corresponding secondary thread with which to compare // aMaster. CSVThread secondary = aSecondaryCol[aMaster.FullName]; if (secondary == null) { // Secondary collection doesn't contain this thread, so make a default entry. secondary = CSVThread.NewDefault(aMaster.FullName); } else { aSecondaryCol.Remove(secondary); } return(secondary); }
private void OnStateComparingAndExportingIndividualDataSets() { // If there are only two sets to compare, then we generate a single output file and that's it. // If we have 3 (or more) data sets, then we will generate three (or more) comparison files, e.g.: // // [File 1] 0 vs 1 // [File 2] 1 vs 2 // // and also // // [File 3] 0 vs 2 // // Etc. int numberOfComparisons = (iDataSets.Count > 2 ? iDataSets.Count : 1); if (iIndex + 1 < iDataSets.Count) { if (eIndexedProgressHandler != null) { eIndexedProgressHandler(TEvent.EEventComparingMovedToNewDataSet, this, iIndex + 1, numberOfComparisons); } // Get sets to compare CSVDataSet set1 = iDataSets[iIndex + 0]; CSVDataSet set2 = iDataSets[iIndex + 1]; // Build excel file name string excelFileName = BuildExcelFileNameForTwoSetComparison(); // Since we've now built the filename it's okay to increment the index ++iIndex; // Create and initiate comparison iWorkerComparatorTwo = new CSVWorkerTwoDataSetComparator(set1, set2, excelFileName); iWorkerComparatorTwo.eObserver += new CSVWorkerTwoDataSetComparator.Observer(WorkerComparatorTwo_Observer); iWorkerComparatorTwo.CompareAndSaveAsync(); ChangeState(TState.EStateComparingAndExportingIndividualDataSets); } else { // Special comparison of first vs last set when comparing // more than two data sets if (iDataSets.Count > 2) { if (eIndexedProgressHandler != null) { eIndexedProgressHandler(TEvent.EEventComparingMovedToNewDataSet, this, numberOfComparisons, numberOfComparisons); } // Special value to indicate first vs last comparison iIndex = KSpecialFirstVsLastComparisonIndex; // Get sets to compare CSVDataSet set1 = iDataSets[0]; CSVDataSet set2 = iDataSets[iDataSets.Count - 1]; // Build excel file name string excelFileName = BuildExcelFileNameForTwoSetComparison(); // Create and initiate comparison if (iWorkerComparatorTwo != null) { iWorkerComparatorTwo.Dispose(); iWorkerComparatorTwo = null; } iWorkerComparatorTwo = new CSVWorkerTwoDataSetComparator(set1, set2, excelFileName); iWorkerComparatorTwo.eObserver += new CSVWorkerTwoDataSetComparator.Observer(WorkerComparatorTwo_Observer); iWorkerComparatorTwo.CompareAndSaveAsync(); ChangeState(TState.EStateComparingAndExportingIndividualDataSets); } else { if (iWorkerComparatorTwo != null) { iWorkerComparatorTwo.Dispose(); iWorkerComparatorTwo = null; } // ChangeState(TState.EStateComparingAllDataSets); OnStateComparingAndExportingAllDataSets(); } } }
internal void Add(CSVDataSet aDataSet) { iDataSets.Add(aDataSet); }