protected async void ButtonQueryCallees_Click(object sender, EventArgs e) { try { var analysisClient = (AnalysisClient)Application.Get("AnalysisClient"); if (analysisClient != null) { string[] tokens = TextBoxPathPrefix.Text.Split(';'); var type = new TypeDescriptor("", tokens[0]); var parameters = new ParameterDescriptor[] { }; var methodDescriptor = new MethodDescriptor(type, tokens[1], true, false, parameters); var invocation = int.Parse(tokens[2]); IEnumerable <MethodDescriptor> result = null; var stopWatch = Stopwatch.StartNew(); if (invocation > 0) { result = await CallGraphQueryInterface.GetCalleesAsync(analysisClient.SolutionManager, methodDescriptor, invocation, ""); } else { result = await CallGraphQueryInterface.GetCalleesAsync(analysisClient.SolutionManager, methodDescriptor); } stopWatch.Stop(); string calleesStr = String.Join("\n", result); TextBox1.Text = String.Format("Callees:{0} \nTime:{1}", calleesStr, stopWatch.ElapsedMilliseconds); Logger.LogInfo(GrainClient.Logger, "Stats", "Query", "Callees of {0} :{1} \nTime:{2}", methodDescriptor, calleesStr, stopWatch.ElapsedMilliseconds); // System.Diagnostics.Trace.TraceInformation("Callees of {0} :{1} \nTime:{2}", methodDescriptor, calleesStr,stopWatch.ElapsedMilliseconds); //var solutionManager = analysisClient.SolutionManager as ISolutionGrain; //var drives = await solutionManager.GetDrives(); //string drivesStr = String.Join("\n", drives); //TextBox1.Text = drivesStr; } else { TextBox1.Text = "SolutionManager is null..."; } } catch (Exception exc) { while (exc is AggregateException) { exc = exc.InnerException; } this.TextBox1.Text = "Error connecting to Orleans: " + exc + " at " + DateTime.Now; } }
public async Task <Tuple <long, long, long> > ComputeRandomQueries(string className, string methodPrejix, int numberOfMethods, int repetitions, string assemblyName = "MyProject", string expId = "DummyExperimentID") { if (String.IsNullOrEmpty(this.ExperimentID)) { this.ExperimentID = expId; } var solutionManager = this.SolutionManager; Random random = new Random(); long sumTime = 0; long maxTime = 0; long minTime = long.MaxValue; long[] times = new long[repetitions]; for (int i = 0; i < repetitions; i++) { int methodNumber = random.Next(numberOfMethods) + 1; var typeDescriptor = new TypeDescriptor("", className, assemblyName); var methodDescriptor = new MethodDescriptor(typeDescriptor, methodPrejix + methodNumber, true); var invocationCount = await CallGraphQueryInterface.GetInvocationCountAsync(solutionManager, methodDescriptor); if (invocationCount > 0) { var invocation = random.Next(invocationCount) + 1; IEnumerable <MethodDescriptor> result = null; var stopWatch = Stopwatch.StartNew(); if (invocation > 0) { result = await CallGraphQueryInterface.GetCalleesAsync(solutionManager, methodDescriptor, invocation, ""); } else { result = await CallGraphQueryInterface.GetCalleesAsync(solutionManager, methodDescriptor); } stopWatch.Stop(); var time = stopWatch.ElapsedMilliseconds; times[i] = time; if (time > maxTime) { maxTime = time; } if (time < minTime) { minTime = time; } sumTime += time; } } if (repetitions > 0) { var avgTime = sumTime / repetitions; var time = DateTime.Now; var results = new QueriesPerSubject() { ExpID = this.ExperimentID, Time = time, Subject = this.subject, Machines = machines, Repeticions = repetitions, AvgTime = avgTime, MinTime = minTime, MaxTime = maxTime, Median = times[repetitions / 2], Observations = "From web", PartitionKey = this.ExperimentID, RowKey = time.ToFileTime().ToString() }; this.AddQueryResults(results); // SaveTable<QueriesPerSubject>("QueryResults", @"Y:\"); return(Tuple.Create <long, long, long>(avgTime, minTime, maxTime)); } return(Tuple.Create <long, long, long>(0, 0, 0)); }
public async Task <Tuple <long, long, long> > ComputeRandomQueries(int repetitions, string expId = "DummyExperimentID") { if (string.IsNullOrEmpty(this.ExperimentID)) { this.ExperimentID = expId; } var solutionManager = this.SolutionManager; var random = new Random(); long sumTime = 0; long maxTime = 0; long minTime = long.MaxValue; long[] times = new long[repetitions]; //var numberOfMethods = await solutionManager.GetReachableMethodsCountAsync(); var warmingUpQueries = 50; for (int i = 0; i < repetitions + warmingUpQueries; i++) { //var methodNumber = random.Next(numberOfMethods); //var methodDescriptor = await solutionManager.GetMethodDescriptorByIndexAsync(methodNumber); var methodDescriptor = await solutionManager.GetRandomMethodAsync(); var invocationCount = await CallGraphQueryInterface.GetInvocationCountAsync(solutionManager, methodDescriptor); if (invocationCount > 0) { var invocation = random.Next(invocationCount) + 1; IEnumerable <MethodDescriptor> result = null; var stopWatch = Stopwatch.StartNew(); if (invocation > 0) { result = await CallGraphQueryInterface.GetCalleesAsync(solutionManager, methodDescriptor, invocation, ""); } else { result = await CallGraphQueryInterface.GetCalleesAsync(solutionManager, methodDescriptor); } stopWatch.Stop(); if (i >= warmingUpQueries) { var time = stopWatch.ElapsedMilliseconds; times[i - warmingUpQueries] = time; if (time > maxTime) { maxTime = time; } if (time < minTime) { minTime = time; } sumTime += time; var currentTime = DateTime.Now; var results = new QueriesDetailPerSubject() { ExpID = this.ExperimentID, Time = currentTime, Subject = this.subject, Machines = machines, QueryNumber = i - warmingUpQueries, QueryTime = time, PartitionKey = this.ExperimentID, RowKey = ExperimentID + "-" + (i - warmingUpQueries) + "-" + currentTime.ToFileTime().ToString() }; this.AddIndividualQueryResult(results); } } } if (repetitions > 0) { var avgTime = sumTime / repetitions; var stdDev = 0D; for (var i = 0; i < times.Length; i++) { stdDev += (times[i] - avgTime) * (times[i] - avgTime); } stdDev = Math.Sqrt(stdDev / repetitions); var time = DateTime.Now; var results = new QueriesPerSubject() { ExpID = this.ExperimentID, Time = time, Subject = this.subject, Machines = machines, Repeticions = repetitions, AvgTime = avgTime, MinTime = minTime, MaxTime = maxTime, StdDev = stdDev, Median = times[repetitions / 2], Observations = "From web", PartitionKey = this.ExperimentID, RowKey = time.ToFileTime().ToString() }; this.AddQueryResults(results); // SaveTable<QueriesPerSubject>("QueryResults", @"Y:\"); return(Tuple.Create <long, long, long>(avgTime, minTime, maxTime)); } return(Tuple.Create <long, long, long>(0, 0, 0)); }
public static IEnumerable <Stopwatch> DoQueries2(ISolutionManager solutionManager) { { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N0", true), 2, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N1", true), 2, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N2", true), 1, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N3", true), 1, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N4", true), 2, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N5", true), 1, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N6", true), 2, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N7", true), 6, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N8", true), 1, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } //{ // var sw = Stopwatch.StartNew(); // var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "N9", true), 1, TestConstants.TestProjectName).Result; // sw.Stop(); // yield return sw; //} { var sw = Stopwatch.StartNew(); var _ = CallGraphQueryInterface.GetCalleesAsync(solutionManager, new MethodDescriptor("C", "Main", true), 9, TestConstants.ProjectName).Result; sw.Stop(); yield return(sw); } }