|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using ErkerTech.DeltaScope.Engine;
namespace ErkerTech.DeltaScope.App.Models
{
public class DeltaScopeEngine
{
public TimeSpan ElapsedTime { get; private set; }
public long PeakMemoryUsage { get; private set; }
public IList<DeltaBlock> Compare(string tsLeftFile, string tsRightFile)
{
GC.Collect();
var process = Process.GetCurrentProcess();
process.Refresh();
var peakWorkingSet64 = process.PeakWorkingSet64;
var sw = new Stopwatch();
sw.Start();
IList<DeltaBlock> results;
using (var deltaEngine = new DeltaEngine())
{
results = deltaEngine.GetDifferences(tsLeftFile, tsRightFile, fileName =>
{
var deltaStrings = new List<DeltaString>();
using (var sr = new StreamReader(fileName))
{
while (!sr.EndOfStream)
deltaStrings.Add(new DeltaString(sr.ReadLine()));
}
return deltaStrings;
});
}
sw.Stop();
ElapsedTime = sw.Elapsed;
process.Refresh();
PeakMemoryUsage = process.PeakWorkingSet64 - peakWorkingSet64;
return results;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.