public void IsDiff_IncompleteDiff_ReturnsFalse() { var diffText = new[] { "--- a/cppupdatr/Refactor/MoveFile.cs", "+++ b/cppupdatr/Refactor/MoveFile.cs", }.StringJoin('\n'); DiffUtils.IsDiff(diffText).ShouldBeFalse(); }
public void IsDiff_ValidLfDiff_ReturnsTrue() { var diffText = new[] { "--- a/cppupdatr/Refactor/MoveFile.cs", "+++ b/cppupdatr/Refactor/MoveFile.cs", "@@ -1,6 +1,7 @@", }.StringJoin('\n'); DiffUtils.IsDiff(diffText).ShouldBeTrue(); }
public void IsDiff_BrokenDiff_ReturnsFalse() { var diffText = new[] { "--- a/cppupdatr/Refactor/MoveFile.cs", " +++ b/cppupdatr/Refactor/MoveFile.cs", "@@ -1,6 +1,7 @@" }.StringJoin('\n'); DiffUtils.IsDiff(diffText).ShouldBeFalse(); }
public int Score(string s1, string s2) { string shorter; string longer; if (s1.Length > s2.Length) { shorter = s2; longer = s1; } else { shorter = s1; longer = s2; } var matchingBlocks = DiffUtils.GetMatchingBlocks(shorter, longer); var scores = new List <double>(); foreach (var block in matchingBlocks) { var dist = block.Dpos - block.Spos; var longStart = dist > 0 ? dist : 0; var longEnd = longStart + shorter.Length; if (longEnd > longer.Length) { longEnd = longer.Length; } var longSubstring = longer.Substring(longStart, longEnd - longStart); var ratio = DiffUtils.GetRatio(shorter, longSubstring); if (ratio > .995) { return(100); } scores.Add(ratio); } return(Convert.ToInt32(scores.Max() * 100)); }
public void IsDiff_EmptyDiff_ReturnsFalse() { DiffUtils.IsDiff("").ShouldBeFalse(); }
private void RunApp() { using (var server = Server.Create("Crimes")) { var host = new ServiceHost(server.CreateManagementService()); host.AddServiceEndpoint(typeof(IManagementService), new WSHttpBinding(SecurityMode.Message), "http://localhost/MyStreamInsightServer"); host.Open(); var crimeApp = server.CreateApplication("serverApp"); progressBar1.Value += 10; FileUtils util = new FileUtils(); PerformanceUtils utilPerf = new PerformanceUtils(); QueryUtils utilQuery = new QueryUtils(util, crimeApp); SeverityUtils utilApp = new SeverityUtils(); DiffUtils utilDiff = new DiffUtils(); var noOfTries = NoOfTriesVal; util.Cleanup("results2"); util.Cleanup("performance"); util.Cleanup("performance2"); progressBar1.Value += 10; utilApp.FullDataRun(crimeApp, util, utilPerf, utilQuery, server); linkLabel1.Visible = true; utilPerf.GetCpuLatency("performance/performanceFull.txt"); progressBar1.Value += 10; var howMany = 1; var avg = 0.0; Dictionary <double, double> avgErrors = new Dictionary <double, double>(); Dictionary <double, double> limit = new Dictionary <double, double>(); Dictionary <double, double> avgCpu = new Dictionary <double, double>(); Dictionary <double, double> avgP = new Dictionary <double, double>(); progressBar1.Value += 10; while (avg >= 0 && avg < 0.5) { utilApp.PartDataRun(crimeApp, util, utilPerf, utilQuery, server, noOfTries, howMany, SeqLengthVal); DirectoryInfo d = new DirectoryInfo(@"C:\Users\BIANCA\Desktop\thesis\Crimes\Crimes\bin\Debug\results2"); FileInfo[] files = d.GetFiles("*.txt"); DirectoryInfo dP = new DirectoryInfo(@"C:\Users\BIANCA\Desktop\thesis\Crimes\Crimes\bin\Debug\performance2"); FileInfo[] filesP = dP.GetFiles("*.txt"); var errors = new List <Dictionary <string, double> >(); var errorsP = new List <Dictionary <string, double> >(); var errorsCpu = new List <Dictionary <string, double> >(); foreach (var file in files) { errors.Add(utilDiff.ComputeDifference("results/result.txt", file.FullName)); } avg = utilDiff.ComputeErrorAverage(errors, "results/severityErrors.txt"); avgErrors.Add(howMany, avg); //Console.WriteLine(avg + " " + howMany); howMany += 1; progressBar1.Maximum += 10; foreach (var f in files) { f.Delete(); } foreach (var file in filesP) { utilPerf.GetCpuLatency(file.FullName); } foreach (var file in filesP) { errorsP.Add(utilDiff.ComputeDifference("performance/performanceFull.txt", file.FullName)); } foreach (var err in errorsP) { var kvp = err.First(); errorsCpu.Add(new Dictionary <string, double> { { kvp.Key, kvp.Value } }); err.Remove(kvp.Key); } var avgPerf = utilDiff.ComputeErrorAverage(errorsP, "latencyErrors.txt"); var ap = (avgPerf / 1000.0) % 60; avgP.Add(howMany, ap); var avgC = utilDiff.ComputeErrorAverage(errorsCpu, "cpuErrors.txt"); avgCpu.Add(howMany, avgC); foreach (var f in filesP) { f.Delete(); } progressBar1.Value += 10; } // progressBar1.Value += 20; Console.WriteLine(avg + " " + howMany); foreach (var a in avgErrors) { limit.Add(a.Key, 0.5); } CreateChart(chart1, avgErrors, limit, "Severity error", "Error limit"); CreateChart(chart2, avgP, avgCpu, "Latency", "Cpu"); linkLabel2.Visible = true; //System.Threading.Thread.Sleep(1000); //progressBar1.Value += 20; host.Close(); } }
public int Score(string s1, string s2) { return(Convert.ToInt32(DiffUtils.GetRatio(s1, s2) * 100)); }