private static void SetCumulativeComponentDependency(this MetricsReport metrics) { foreach (var type in metrics.Types) { type.CumulativeComponentDependency = CumulativeComponentDependency.Of(type, metrics.GraphOfTypes); } }
public static IEnumerable <NamespaceMetricsReport> NamespacesOverLimit <T>(this MetricsReport metrics, Func <NamespaceMetricsReport, T> metricSelector, Func <RatingFunctionLimits, Func <CommonReportKnowledge, T> > limitSelector) where T : IComparable <T> { return(from namespaceMetric in metrics.Namespaces where metricSelector(namespaceMetric).CompareTo(limitSelector(RatingFunctions.Limits)(metrics.CommonKnowledge)) > 0 select namespaceMetric); }
/// <summary> /// Schedule a generic reporter to be executed at a fixed <paramref name="interval"/> /// </summary> /// <param name="report">Function that returns an instance of a reporter</param> /// <param name="interval">Interval at which to run the report.</param> /// <param name="filter">Only report metrics that match the filter.</param> public MetricsReports WithReport(MetricsReport report, TimeSpan interval, MetricsFilter filter = null) { var newReport = new ScheduledReporter(report, this.metricsDataProvider.WithFilter(filter), this.healthStatus, interval); this.reports.Add(newReport); return(this); }
public void Ensure_MetricsReportIsAvailable() { if (Metrics == null) { Metrics = Analyze.Me(); } }
private static void SetInterestingDirectDependencies(this MetricsReport metrics) { foreach (var type in metrics.Types) { type.InterestingDirectDependencies = InterestingDirectDependencies.Of(type, metrics.Types); } }
private void OutputMetricsReport(MetricsReport metrics) { foreach (var namespaceMetrics in metrics.Namespaces) { OutputNamespaceMetricsReport(namespaceMetrics); } OutputSeperator(2); foreach (var type in metrics.Types.Where(t => !t.CompilerGenerated)) { OutputTypeMetricsReport(type); } OutputSeperator(2); foreach (var method in metrics.Methods.Where(m => !m.CompilerGenerated && !m.OnlyDeclaration)) { OutputMethodMetricsReport(method); } OutputSeperator(3); OutputRatings(metrics.Rate()); OutputHotspots(metrics.Hotspots()); }
/// <summary> /// Schedule a generic reporter to be executed at a fixed <paramref name="interval"/> /// </summary> /// <param name="report">Function that returns an instance of a reporter</param> /// <param name="interval">Interval at which to run the report.</param> public MetricsReports WithReport(MetricsReport report, TimeSpan interval) { var newReport = new ScheduledReporter(report, this.metricsDataProvider, this.healthStatus, interval); this.ScheduledReporters.Add(newReport); return(this); }
private static IEnumerable <MethodAndTypeMetrics> GetMethodOfLine(this MetricsReport metrics, LineLocation location) { return(from type in metrics.Types from method in metrics.MethodsOfType(type) where IsMethodAtLine(method, location) select new MethodAndTypeMetrics(type, method)); }
public PreparedMetricsReport Prepare(MetricsReport metrics) { var preparedMetrics = new PreparedMetricsReport(metrics, _lastMetrics); _lastMetrics = metrics; return(preparedMetrics); }
internal PreparedMetricsReport(MetricsReport metrics, MetricsReport lastMetrics) { Report = metrics; PreviousReport = lastMetrics; ThrowExceptionWhenNoMetrics(); Prepare(); }
private PreparedMetricsReport AnalyzeProjectFiles(string[] files) { MetricsReport metrics = ShouldUseParallelism() ? AnalyzeParallel.PortableExecutables(files) : Analyze.PortableExecutables(files); return(metricsFactory.Prepare(metrics)); }
public ScheduledReporter(MetricsReport report, MetricsDataProvider metricsDataProvider, Func <HealthStatus> healthStatus, TimeSpan interval, Scheduler scheduler) { this.report = report; this.metricsDataProvider = metricsDataProvider; this.healthStatus = healthStatus; this.scheduler = scheduler; this.scheduler.Start(interval, t => RunReport(t)); }
public static IEnumerable <MethodMetricsReport> MethodsOverLimit <T>(this MetricsReport metrics, Func <MethodMetricsReport, T> metricSelector, Func <RatingFunctionLimits, Func <CommonReportKnowledge, T> > limitSelector, Func <MethodMetricsReport, bool> condition) where T : IComparable <T> { return(from method in metrics.Methods where condition(method) where metricSelector(method).CompareTo(limitSelector(RatingFunctions.Limits)(metrics.CommonKnowledge)) > 0 select method); }
public static IEnumerable <TypeMetricsReport> TypesOverLimit <T>(this MetricsReport metrics, Func <TypeMetricsReport, T> metricSelector, Func <RatingFunctionLimits, Func <CommonReportKnowledge, T> > limitSelector, Func <TypeMetricsReport, bool> condition) where T : IComparable <T> { return(from type in metrics.Types where condition(type) where metricSelector(type).CompareTo(limitSelector(RatingFunctions.Limits)(metrics.CommonKnowledge)) > 0 select type); }
public static MethodAndTypeMetrics MethodOfLine(this MetricsReport metrics, LineLocation location) { if (metrics == null) { return(null); } return((metrics.GetMethodOfLine(location)).FirstOrDefault()); }
public ScheduledReporter(MetricsReport report, MetricsDataProvider metricsDataProvider, Func<HealthStatus> healthStatus, TimeSpan interval, Scheduler scheduler) { this.report = report; this.metricsDataProvider = metricsDataProvider; this.healthStatus = healthStatus; this.scheduler = scheduler; this.scheduler.Start(interval, t => RunReport(t)); }
/// <summary> /// Schedule a generic reporter to be executed at a fixed <paramref name="interval"/> /// </summary> /// <param name="report">Function that returns an instance of a reporter</param> /// <param name="interval">Interval at which to run the report.</param> /// <param name="filter">Only report metrics that match the filter.</param> public MetricsReports WithReport(MetricsReport report, TimeSpan interval, MetricsFilter filter = null) { var toleratedConsecutiveFailures = ReadToleratedFailuresConfig(); var newReport = new ScheduledReporter(report, this.metricsDataProvider.WithFilter(filter), this.healthStatus, interval, new ActionScheduler(toleratedConsecutiveFailures)); this.reports.Add(newReport); return(this); }
internal static MetricsReport Combine(this MetricsReport[] reports) { var report = MetricsReport.Of(reports); report.Remember.AssemblyAnalysisDone(); report.PostProcess(); report.Remember.PostProcessingDone(); return(report); }
private static IEnumerable <T> MethodsNotGenerated <T>(this MetricsReport metrics, Func <MethodMetricsReport, T> selector) { return(from m in metrics.Methods where !m.CompilerGenerated where !m.OnlyDeclaration where m.CyclomaticComplexity > 0 where m.MethodLength > 0 select selector(m)); }
private void InitializeStatistics(MetricsReport metrics) { AverageRatedCyclomaticComplexity = RatedMethods.AverageAny(m => m.RatedCyclomaticComplexity, m => m.CyclomaticComplexity > 0); AverageRatedMethodLength = RatedMethods.AverageAny(m => m.RatedMethodLength, m => m.MethodLength > 0); AverageRatedClassSize = RatedTypes.AverageAny(m => m.RatedClassSize); AverageRatedNumberOfNonStaticPublicFields = RatedTypes.AverageAny(m => m.RatedNumberOfNonStaticPublicFields); AverageComponentDependency = RatedTypes.AverageAny(m => m.CumulativeComponentDependency) / metrics.CommonKnowledge.NumberOfTypes; NamespacesWithCyclicDependencies = (double)RatedNamespaces.CountAny(m => m.IsInCycle) / metrics.CommonKnowledge.NumberOfNamespaces; }
private static void SetNamespacesWithCyclicDependencies(this MetricsReport metrics) { var cycles = CyclicDependencies.In(metrics.GraphOfNamespaces); foreach (var namespaceWithTypes in metrics.GraphOfNamespaces.Vertices) { metrics.AddNamespaceReport(namespaceWithTypes); namespaceWithTypes.Namespace.CyclicDependencies = CyclicDependencies.Of(namespaceWithTypes, cycles); } }
internal static MetricsReport MetricsReport(params TypeMetricsWithMethodMetrics[] typeMetrics) { var metricsReport = new MetricsReport(); foreach (var typeMetric in typeMetrics) { metricsReport.AddTypeReport(TypeMetrics(typeMetric.Type, typeMetric.Methods)); } return(metricsReport); }
public static MetricsReport MetricsReport(IEnumerable <TypeMetricsReport> typeMetrics) { var metricsReport = new MetricsReport(); foreach (var typeMetric in typeMetrics) { metricsReport.AddTypeReport(TypeMetrics(typeMetric, Enumerable.Empty <MethodMetricsReport>())); } return(metricsReport); }
public static MetricsReport MetricsReport(IEnumerable <NamespaceMetricsReport> namespaceMetrics) { var metricsReport = new MetricsReport(); foreach (var namespaceMetric in namespaceMetrics) { metricsReport.AddNamespaceReport(NamespaceMetrics(namespaceMetric, Enumerable.Empty <TypeMetricsReport>())); } return(metricsReport); }
public static MetricsReport MetricsReport(IEnumerable <MethodMetricsReport> methodMetrics) { var metricsReport = new MetricsReport(); metricsReport.AddTypeReport(TypeMetrics(new TypeMetricsReport() { FullName = RandomName() }, methodMetrics)); return(metricsReport); }
private static TypeMetricsReport GetTypeMetrics(this MetricsReport metrics, Type type) { var typeMetrics = metrics.ForType(type); if (typeMetrics != null) { return(typeMetrics); } throw new MetricsNotFoundException(type); }
private static MethodMetricsReport GetMethodMetrics(this MetricsReport metrics, MethodInfo method) { var methodMetrics = metrics.ForMethod(method); if (methodMetrics != null) { return(methodMetrics); } throw new MetricsNotFoundException(method); }
private static bool VerifyType <T>(this T expectation, Type type, MetricsReport metrics) where T : TypeExpectation { Debug.WriteLine("verify " + type.Name); var typeMetrics = metrics.GetTypeMetrics(type); if (expectation.Verify(typeMetrics)) { return(true); } throw new VerificationException(type, expectation); }
private static bool VerifyMethod <T>(this T expectation, MethodInfo method, MetricsReport metrics) where T : MethodExpectation { Debug.WriteLine("verify " + method.Name); var methodMetrics = metrics.GetMethodMetrics(method); if (expectation.Verify(methodMetrics)) { return(true); } throw new VerificationException(method, expectation); }
public PerfCounterReporter(MetricsReport report, TimeSpan interval, ICounterSamplingConfiguration counterSamplingConfig) { _report = report; _counterSamplingConfig = counterSamplingConfig; _handler = new PdhPathHandler(); _healthStatus = new HealthStatus(); _timers = new ConcurrentDictionary<string, MetricInfo>(); _currentMetrics = new Dictionary<string, MetricInfo>(); _couunterReporters = new List<CounterReporter>(); this._reportScheduler = new ActionScheduler(); this._reportScheduler.Start(interval, t => RunReport(t)); this._timerScheduler = new ActionScheduler(); this._timerScheduler.Start(TimeSpan.FromSeconds(1), t => ReportMetrics()); }
public PerfCounterReporter(MetricsReport report, TimeSpan interval, ICounterSamplingConfiguration counterSamplingConfig) { _report = report; _counterSamplingConfig = counterSamplingConfig; _handler = new PdhPathHandler(); _healthStatus = new HealthStatus(); _timers = new ConcurrentDictionary <string, MetricInfo>(); _currentMetrics = new Dictionary <string, MetricInfo>(); _couunterReporters = new List <CounterReporter>(); this._reportScheduler = new ActionScheduler(); this._reportScheduler.Start(interval, t => RunReport(t)); this._timerScheduler = new ActionScheduler(); this._timerScheduler.Start(TimeSpan.FromSeconds(1), t => ReportMetrics()); }
public ScheduledReporter(MetricsReport reporter, MetricsDataProvider metricsDataProvider, Func<HealthStatus> healthStatus, TimeSpan interval) : this(reporter, metricsDataProvider, healthStatus, interval, new ActionScheduler()) { }
public ScheduledReporter(MetricsReport reporter, MetricsDataProvider metricsDataProvider, Func <HealthStatus> healthStatus, TimeSpan interval) : this(reporter, metricsDataProvider, healthStatus, interval, new ActionScheduler()) { }
/// <summary> /// Schedule a generic reporter to be executed at a fixed <paramref name="interval"/> /// </summary> /// <param name="report">Function that returns an instance of a reporter</param> /// <param name="interval">Interval at which to run the report.</param> public MetricsReports WithReport(MetricsReport report, TimeSpan interval) { var newReport = new ScheduledReporter(report, this.metricsDataProvider, this.healthStatus, interval); this.reports.Add(newReport); return this; }