public CSVWorkerAllDataSetComparator(CSVDataSetCollection aDataSets, string aOutputFileName)
 {
     // Create our list of sorted comparison pairs.
     iDataSets            = aDataSets;
     iUniqueThreadDetails = IdentifyAllThreadNames();
     iExcelExporter       = new CSVExcelExporterAllDataSets(aOutputFileName, iUniqueThreadDetails, aDataSets.Count);
 }
        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;
        }