public InSituMethodInvocationControlViewModel(MethodPerformanceInfo methodPerformanceInfo)
        {
            MethodPerformanceInfo = methodPerformanceInfo ?? throw new ArgumentNullException(nameof(methodPerformanceInfo));
            OpenDetailViewCommand = new RelayCommand <object>(obj => OnOpenDetailViewCommand());

            MethodPerformanceInfo.PropertyChanged += MethodPerformanceInfoPropertyChanged;
        }
        /// <summary>
        /// Predicts Method Execution Time
        /// sums up callee times for methods
        /// </summary>
        public TimeSpan PredictMethodTime(MethodPerformanceInfo methodPerformanceInfo, object[] parameters)
        {
            // TODO RR: multiply by 1 + workolad
            var executionTimeWithoutLoops = methodPerformanceInfo.AllCalleePerformanceInfo.Sum(p => p.ExecutionTime);

            if (!methodPerformanceInfo.LoopPerformanceInfos.Any())
            {
                return(executionTimeWithoutLoops);
            }
            var singleIterationTime = methodPerformanceInfo.LoopPerformanceInfos.Sum(p => p.SingleIterationTime);
            var predictedLoopTime   = methodPerformanceInfo.LoopPerformanceInfos.Sum(p => p.ExecutionTime);

            return(executionTimeWithoutLoops - singleIterationTime + predictedLoopTime);
        }
        public async Task <MethodPerformanceInfo> GetMethodPerformanceInfoAsync(IMethodSymbol methodSymbol)
        {
            var documentationCommentId = methodSymbol.GetDocumentationCommentId();

            if (_methodPerformancInfoCache.TryGetValue(documentationCommentId, out var existingMethodPerformanceInfo))
            {
                return(existingMethodPerformanceInfo);
            }

            // TODO RR: Use SyntaxAnnotation https://joshvarty.wordpress.com/2015/09/18/learn-roslyn-now-part-13-keeping-track-of-syntax-nodes-with-syntax-annotations/
            // TODO RR: Do one Dictionary per Class/File
            var methodTelemetry = await _telemetryProvider.GetTelemetryDataAsync(documentationCommentId).ConfigureAwait(false);

            if (methodTelemetry == null)
            {
                return(null);
            }

            var performanceInfo = new MethodPerformanceInfo(_predictionEngine, methodSymbol, methodTelemetry);

            _methodPerformancInfoCache.Add(documentationCommentId, performanceInfo);
            return(performanceInfo);
        }
Example #4
0
        private async Task <LoopPerformanceInfo> VisitLoopAsync(SyntaxNode loopSyntax, MethodPerformanceInfo methodPerformanceInfo)
        {
            var invocationExpressionSyntaxsInLoop = loopSyntax.DescendantNodes(node => true).OfType <InvocationExpressionSyntax>();
            var loopInvocationsList = new List <MethodPerformanceInfo>();

            foreach (var invocationExpressionSyntax in invocationExpressionSyntaxsInLoop)
            {
                var invokedMethodSymbol = _semanticModel.GetSymbolInfo(invocationExpressionSyntax).Symbol as IMethodSymbol;
                // Only Drawing invocationSymbols that refer to the current assembly. Not drawing Information about other assemblies...
                if (invokedMethodSymbol == null || !Equals(_semanticModel.Compilation.Assembly, invokedMethodSymbol.ContainingAssembly))
                {
                    continue;
                }
                var invocationPerformanceInfo = await _telemetryDataMapper.GetMethodPerformanceInfoAsync(invokedMethodSymbol).ConfigureAwait(false);

                loopInvocationsList.Add(invocationPerformanceInfo);
            }


            var loopPerformanceInfo = new LoopPerformanceInfo(_predictionEngine, methodPerformanceInfo, loopInvocationsList);

            var derivedLoopIterations = TryGetLoopIterationsFromCodeFlow(loopSyntax);

            if (derivedLoopIterations != 0)
            {
                loopPerformanceInfo.PredictedLoopIterations = derivedLoopIterations;
            }

            PerformanceTags.Add(loopSyntax, new LoopPerformanceTag(loopPerformanceInfo));
            return(loopPerformanceInfo);
        }
Example #5
0
 public MethodInvocationPerformanceTag(MethodPerformanceInfo performanceInfo) : base(performanceInfo)
 {
 }
Example #6
0
 internal PerformanceTag(MethodPerformanceInfo performanceInfo)
 {
     PerformanceInfo = performanceInfo;
 }
Example #7
0
 public MethodPerformanceTag(MethodPerformanceInfo performanceInfo) : base(performanceInfo)
 {
 }