Exemplo n.º 1
0
        private Series LoadCpuSeries(WorkloadAnalysis analysis, OxyColor color, double baseOffset)
        {
            if (analysis == null)
            {
                return(null);
            }

            LineSeries cpuSeries = new LineSeries()
            {
                StrokeThickness             = 2,
                MarkerSize                  = 3,
                MarkerStroke                = OxyColor.Parse("#FF0000"), //Red
                MarkerType                  = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                Title  = analysis.Name,
                Color  = color,
                Smooth = false
            };

            if (baseOffset == 0)
            {
                cpuSeries.TrackerFormatString = "Offset: {2:0}\n{0}: {4:0}";
            }

            var Table = from t in analysis.Points
                        where ApplicationList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.ApplicationName) &&
                        HostList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.HostName) &&
                        DatabaseList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.DatabaseName) &&
                        LoginList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.LoginName)
                        group t by new
            {
                offset = t.OffsetMinutes
            }
            into grp
            orderby grp.Key.offset
                select new
            {
                offset_minutes = grp.Key.offset,
                cpu            = grp.Sum(t => t.SumCpuUs)
            };



            foreach (var p in Table)
            {
                double xValue = 0;
                if (baseOffset > 0)
                {
                    xValue = DateTimeAxis.ToDouble(DateTimeAxis.ToDateTime(baseOffset).AddMinutes(p.offset_minutes));
                }
                else
                {
                    xValue = p.offset_minutes;
                }
                cpuSeries.Points.Add(new DataPoint(xValue, p.cpu));
            }

            return(cpuSeries);
        }
Exemplo n.º 2
0
        private Series LoadBatchesSeries(WorkloadAnalysis analysis, OxyColor color)
        {
            if (analysis == null)
            {
                return(null);
            }

            LineSeries batchesSeries = new LineSeries()
            {
                StrokeThickness             = 2,
                MarkerSize                  = 3,
                MarkerStroke                = OxyColor.Parse("#FF0000"), //Red
                MarkerType                  = MarkerType.None,
                CanTrackerInterpolatePoints = false,
                TrackerFormatString         = "Offset: {2:0}\n{0}: {4:0}",
                Title  = analysis.Name,
                Color  = color,
                Smooth = false
            };


            var Table = from t in analysis.Points
                        where ApplicationList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.ApplicationName) &&
                        HostList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.HostName) &&
                        DatabaseList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.DatabaseName) &&
                        LoginList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.LoginName)
                        group t by new
            {
                offset = t.OffsetMinutes
            }
            into grp
            orderby grp.Key.offset
                select new
            {
                offset_minutes  = grp.Key.offset,
                execution_count = grp.Sum(t => t.ExecutionCount / ((t.DurationMinutes == 0 ? 1 : t.DurationMinutes) * 60))
            };

            foreach (var p in Table)
            {
                batchesSeries.Points.Add(new DataPoint(p.offset_minutes, p.execution_count));
            }

            return(batchesSeries);
        }
Exemplo n.º 3
0
        private void InitializeQueries()
        {
            // Initialize the queries
            logger.Info("Entering baseline evaluation");

            bool zoomIsSet = PlotModels[0].DefaultXAxis != null;

            double xstart = 0;
            double xend   = 0;

            if (zoomIsSet)
            {
                xstart = PlotModels[0].DefaultXAxis.ActualMinimum;
                xend   = PlotModels[0].DefaultXAxis.ActualMaximum;
                if (xstart < 0)
                {
                    xstart = 0;
                }
            }

            var baseline = from t in _baselineWorkloadAnalysis.Points
                           where ApplicationList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.ApplicationName) &&
                           HostList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.HostName) &&
                           DatabaseList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.DatabaseName) &&
                           LoginList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.LoginName) &&
                           (!zoomIsSet || t.OffsetMinutes >= xstart) &&
                           (!zoomIsSet || t.OffsetMinutes <= xend)
                           group t by new
            {
                query = t.NormalizedQuery
            }
            into grp
                select new
            {
                query           = grp.Key.query,
                sum_duration_us = grp.Sum(t => t.SumDurationUs),
                avg_duration_us = grp.Average(t => t.AvgDurationUs),
                sum_cpu_us      = grp.Sum(t => t.SumCpuUs),
                avg_cpu_us      = grp.Average(t => t.AvgCpuUs),
                sum_reads       = grp.Sum(t => t.SumReads),
                avg_reads       = grp.Average(t => t.AvgReads),
                execution_count = grp.Sum(t => t.ExecutionCount)
            };

            logger.Info("Baseline evaluation completed");
            logger.Info("Entering benchmark evaluation");

            var benchmark = from t in baseline where false select new { t.query, t.sum_duration_us, t.avg_duration_us, t.sum_cpu_us, t.avg_cpu_us, t.sum_reads, t.avg_reads, t.execution_count };

            if (_benchmarkWorkloadAnalysis != null)
            {
                benchmark = from t in _benchmarkWorkloadAnalysis.Points
                            where ApplicationList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.ApplicationName) &&
                            HostList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.HostName) &&
                            DatabaseList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.DatabaseName) &&
                            LoginList.Where(f => f.IsChecked).Select(f => f.Name).Contains(t.LoginName) &&
                            (!zoomIsSet || t.OffsetMinutes >= xstart) &&
                            (!zoomIsSet || t.OffsetMinutes <= xend)
                            group t by new
                {
                    query = t.NormalizedQuery
                }
                into grp
                    select new
                {
                    query           = grp.Key.query,
                    sum_duration_us = grp.Sum(t => t.SumDurationUs),
                    avg_duration_us = grp.Average(t => t.AvgDurationUs),
                    sum_cpu_us      = grp.Sum(t => t.SumCpuUs),
                    avg_cpu_us      = grp.Average(t => t.AvgCpuUs),
                    sum_reads       = grp.Sum(t => t.SumReads),
                    avg_reads       = grp.Average(t => t.AvgReads),
                    execution_count = grp.Sum(t => t.ExecutionCount)
                };
            }

            logger.Info("Benchmark evaluation completed");
            logger.Info("Merging sets");

            var leftOuterJoin =
                from b in baseline
                join k in benchmark
                on b.query.Hash equals k.query.Hash
                into joinedData
                from j in joinedData.DefaultIfEmpty()
                select new
            {
                query_hash       = b.query.Hash,
                query_text       = b.query.ExampleText,
                query_normalized = b.query.NormalizedText,
                b.sum_duration_us,
                b.avg_duration_us,
                b.sum_cpu_us,
                b.avg_cpu_us,
                b.sum_reads,
                b.avg_reads,
                b.execution_count,
                sum_duration_us2     = j == null ? 0 : j.sum_duration_us,
                diff_sum_duration_us = j == null ? 0 : j.sum_duration_us - b.sum_duration_us,
                avg_duration_us2     = j == null ? 0 : j.avg_duration_us,
                sum_cpu_us2          = j == null ? 0 : j.sum_cpu_us,
                diff_sum_cpu_us      = j == null ? 0 : j.sum_cpu_us - b.sum_cpu_us,
                avg_cpu_us2          = j == null ? 0 : j.avg_cpu_us,
                sum_reads2           = j == null ? 0 : j.sum_reads,
                avg_reads2           = j == null ? 0 : j.avg_reads,
                execution_count2     = j == null ? 0 : j.execution_count,
                querydetails         = new QueryDetails(b.query, _baselineWorkloadAnalysis, _benchmarkWorkloadAnalysis),
                document             = new ICSharpCode.AvalonEdit.Document.TextDocument()
                {
                    Text = b.query.ExampleText
                }
            };

            var rightOuterJoin =
                from b in benchmark
                join k in baseline
                on b.query.Hash equals k.query.Hash
                into joinedData
                from j in joinedData.DefaultIfEmpty()
                select new
            {
                query_hash       = b.query.Hash,
                query_text       = b.query.ExampleText,
                query_normalized = b.query.NormalizedText,
                b.sum_duration_us,
                b.avg_duration_us,
                b.sum_cpu_us,
                b.avg_cpu_us,
                b.sum_reads,
                b.avg_reads,
                b.execution_count,
                sum_duration_us2     = j == null ? 0 : j.sum_duration_us,
                diff_sum_duration_us = j == null ? 0 : j.sum_duration_us - b.sum_duration_us,
                avg_duration_us2     = j == null ? 0 : j.avg_duration_us,
                sum_cpu_us2          = j == null ? 0 : j.sum_cpu_us,
                diff_sum_cpu_us      = j == null ? 0 : j.sum_cpu_us - b.sum_cpu_us,
                avg_cpu_us2          = j == null ? 0 : j.avg_cpu_us,
                sum_reads2           = j == null ? 0 : j.sum_reads,
                avg_reads2           = j == null ? 0 : j.avg_reads,
                execution_count2     = j == null ? 0 : j.execution_count,
                querydetails         = new QueryDetails(b.query, _baselineWorkloadAnalysis, _benchmarkWorkloadAnalysis),
                document             = new ICSharpCode.AvalonEdit.Document.TextDocument()
                {
                    Text = b.query.ExampleText
                }
            };

            var merged = leftOuterJoin.Union(rightOuterJoin);

            Queries = merged;

            logger.Info("Sets merged");

            RaisePropertyChanged("Queries");
            RaisePropertyChanged("CompareModeVisibility");
            RaisePropertyChanged("CompareMode");

            string sortCol = CompareMode ? "diff_sum_duration_us" : "sum_duration_us";
            var    msg     = new SortColMessage(sortCol, System.ComponentModel.ListSortDirection.Descending);

            Messenger.Default.Send <SortColMessage>(msg);
        }