public Task <string> AnalyzeSolutionAsync(string drive, string solutionPath, string solutionName, int machines, string expID, string rootKind = "Default")
        {
            var result = string.Empty;

            try
            {
                if (string.IsNullOrEmpty(expID))
                {
                    expID = solutionName;
                }
                solutionPath = Path.Combine(drive + ":\\" + solutionPath, solutionName + ".sln");
                var analyzer       = SolutionAnalyzer.CreateFromSolution(GrainClient.Instance, solutionPath);
                var analysisClient = new AnalysisClient(analyzer, machines);

                //var results = await analysisClient.RunExperiment(GrainClient.GrainFactory, expID);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                analysisClient.StartRunningExperiment(GrainClient.GrainFactory, expID, Utils.ToAnalysisRootKind(rootKind));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                //result = string.Format("Ready for queries. Time: {0} ms", results.ElapsedTime);
                result = string.Format("Analyzing solution {0}.", solutionName);
            }
            catch (Exception exc)
            {
                while (exc is AggregateException)
                {
                    exc = exc.InnerException;
                }
                result = "Error connecting to Orleans: " + exc + " at " + DateTime.Now;
            }

            return(Task.FromResult(result));
        }
Esempio n. 2
0
        private SolutionAnalyzer RunAnalysis(string solutionPath)
        {
            System.Console.WriteLine("Analyzing solution...");

            var analyzer = SolutionAnalyzer.CreateFromSolution(GrainClient.Instance, solutionPath);

            analyzer.RootKind = AnalysisRootKind.RootMethods;

            var timer = Stopwatch.StartNew();

            analyzer.AnalyzeAsync(strategyKind).Wait();

            timer.Stop();

            System.Console.WriteLine("Solution analysis finish ({0} ms)", timer.ElapsedMilliseconds);

            System.Console.WriteLine();
            var color = System.Console.ForegroundColor;

            System.Console.ForegroundColor = ConsoleColor.White;
            var rootMethods = analyzer.SolutionManager.GetRootsAsync().Result;

            System.Console.WriteLine("Root methods={0} ({1})", rootMethods.Count(), analyzer.RootKind);

            var reachableMethodsCount = analyzer.SolutionManager.GetReachableMethodsCountAsync().Result;

            System.Console.WriteLine("Reachable methods={0}", reachableMethodsCount);
            System.Console.ForegroundColor = color;
            System.Console.WriteLine();

            return(analyzer);
        }
        protected void ButtonTestSolution_Click(object sender, EventArgs e)
        {
            try
            {
                this.TextBox1.Text = "Accessing Grains...";
                var solutionPath = TextBoxPath.Text;
                var pathPrefix   = TextBoxPathPrefix.Text;

                try
                {
                    var tokens          = TextRandomQueryInput.Text.Split(';');
                    var className       = tokens[0];
                    var methodPrejix    = tokens[1];
                    var numberOfMethods = int.Parse(tokens[2]);
                    var repetitions     = int.Parse(tokens[3]);
                    var machines        = int.Parse(tokens[4]);
                    var rootKind        = Utils.ToAnalysisRootKind(tokens[5]);

                    var solutionFileName = Path.Combine(pathPrefix, solutionPath);
                    var analyzer         = SolutionAnalyzer.CreateFromSolution(GrainClient.Instance, solutionFileName);

                    var analysisClient = new AnalysisClient(analyzer, machines);
                    //await analysisClient.Analyze();

                    //await analysisClient.RunExperiment(GrainClient.GrainFactory, solutionPath.Replace('\\','-').Replace('.','-'));
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    analysisClient.StartRunningExperiment(GrainClient.GrainFactory, solutionPath.Replace('\\', '-').Replace('.', '-'), rootKind);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                    //var reachableMethods = await RunAnalysisAsync(machines, pathPrefix, solutionPath);
                    //string methods = String.Join("\n", reachableMethods);
                    //this.TextBox1.Text = string.Format("Reachable methods={0} \n{1}", reachableMethods.Count, methods);
                    this.TextBox1.Text = "Done";
                }
                catch (Exception exc)
                {
                    while (exc is AggregateException)
                    {
                        exc = exc.InnerException;
                    }
                    System.Diagnostics.Trace.TraceError("Error dutring initialization of WorkerRole {0}", exc.ToString());
                    this.TextBox1.Text = exc.ToString();
                }
            }
            catch (Exception exc)
            {
                while (exc is AggregateException)
                {
                    exc = exc.InnerException;
                }

                this.TextBox1.Text = "Error connecting to Orleans: " + exc + " at " + DateTime.Now;
            }
        }
Esempio n. 4
0
        private void InitializeAnalysis(string solutionPath)
        {
            Console.WriteLine("Analyzing solution...");

            this.Initialize();
            this.solutionPath = solutionPath;
            this.analyzer     = SolutionAnalyzer.CreateFromSolution(GrainClient.Instance, solutionPath);
            analyzer.AnalyzeAsync(strategyKind).Wait();

            OrleansController.SolutionManager = analyzer.SolutionManager;

            Console.WriteLine("Done");
        }
        private static async Task <ISet <MethodDescriptor> > RunAnalysisAsync(int machines, string pathPrefix, string solutionRelativePath)
        {
            var currentSolutionPath = pathPrefix;
            var solutionFileName    = Path.Combine(currentSolutionPath, solutionRelativePath);

            var analyzer = SolutionAnalyzer.CreateFromSolution(GrainClient.Instance, solutionFileName);

            var analysisClient = new AnalysisClient(analyzer, machines);
            var callgraph      = await analysisClient.Analyze();

            var reachableMethods = callgraph.GetReachableMethods();

            return(await Task.FromResult(reachableMethods));
        }
        public static void AnalyzeSolution(string solutionPath, RunChecks checker, AnalysisStrategyKind strategy = AnalysisStrategyKind.NONE)
        {
            Environment.SetEnvironmentVariable("MyIPAddr", "127.0.0.1");

            var solAnalyzer = SolutionAnalyzer.CreateFromSolution(GrainClient, solutionPath, AnalysisRootKind.MainMethods);
            var callgraph   = solAnalyzer.Analyze(strategy);

            if (strategy == AnalysisStrategyKind.ONDEMAND_ORLEANS)
            {
                var myStatsGrain = StatsHelper.GetStatGrain(GrainClient);
                myStatsGrain.ResetStats().Wait();
            }

            checker(solAnalyzer, callgraph);
        }
Esempio n. 7
0
        public async Task AnalyzeSolutionAsync(string solutionPath, AnalysisStrategyKind strategyKind = StrategyKind)
        {
            {
                // Hack! Remove these lines
                //var solutionToTest = @"ConsoleApplication1\ConsoleApplication1.sln";
                var solutionToTest = @"coby\Coby.sln";
                solutionPath = Path.Combine(OrleansController.ROOT_DIR, solutionToTest);
            }

            OrleansController.solutionPath = solutionPath;
            OrleansController.analyzer     = SolutionAnalyzer.CreateFromSolution(GrainClient.Instance, solutionPath);
            await analyzer.AnalyzeAsync(strategyKind);

            // This call is to fill the documentsAssemblyName mapping
            await GetAllFilesAsync();
        }