Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PerformanceAnalysisViewModel"/> class.
        /// </summary>
        public PerformanceAnalysisViewModel()
        {
            m_rawData   = GraphicsCore.Current.PerformanceCalculator;
            m_snapshots = new ObservableCollection <PerformanceSnapshot>();

            this.MakeSnapshot = new DelegateCommand(OnCommandMakeSnapshot);
        }
Ejemplo n.º 2
0
        protected Size GetLabelSize(TreeNodeAdv node, DrawContext context, string label)
        {
            PerformanceAnalyzer.Start("GetLabelSize");
            CheckThread();
            Font font = GetDrawingFont(node, context, label);
            Size s    = Size.Empty;

            if (UseCompatibleTextRendering)
            {
                s = TextRenderer.MeasureText(label, font, s, TextFormatFlags.NoPrefix);
            }
            else
            {
                SizeF sf = context.Graphics.MeasureString(label, font);
                s = new Size((int)Math.Ceiling(sf.Width), (int)Math.Ceiling(sf.Height));
            }
            PerformanceAnalyzer.Finish("GetLabelSize");

            if (!s.IsEmpty)
            {
                return(s);
            }
            else
            {
                return(new Size(10, Font.Height));
            }
        }
Ejemplo n.º 3
0
        private List <Range <Int32> > FindMatchingKeyworkRanges(Item resultItem)
        {
            var ranges = new List <Range <Int32> >();

            var analyzer = new PerformanceAnalyzer();

            foreach (var keyword in resultItem.Keywords)
            {
                if (!string.IsNullOrEmpty(keyword))
                {
                    var startIndex = 0;

                    while ((startIndex = resultItem.UpperCaseNames.IndexOf(keyword, startIndex)) != -1)
                    {
                        int endIndex = (startIndex + keyword.Length);

                        // TODO: How is it possible?
                        if (endIndex > resultItem.UpperCaseNames.Length)
                        {
                            endIndex = resultItem.UpperCaseNames.Length;
                        }

                        ranges.Add(new Range <Int32>()
                        {
                            Start = startIndex++, End = endIndex
                        });
                    }
                }
            }


            return(ranges);
        }
Ejemplo n.º 4
0
        void FillDatabase(IDatabaseDictionary databaseDictionary)
        {
            var analyzer = new PerformanceAnalyzer();

            Database d = null;

            if (server.Databases.Contains(databaseDictionary.DatabaseName))
            {
                d = server.Databases[databaseDictionary.DatabaseName];
            }
            else
            {
                log.Error("Database name could not be found: " + databaseDictionary.DatabaseName + "; loader failed");
                return;
            }

            databaseDictionary.Clear();

            // do not need to refresh database RefresDatabase(d);

            log.Performance("Refreshing database " + databaseDictionary.DatabaseName, analyzer.Result);

            LoadObjects(d, databaseDictionary);
            databaseDictionary.MarkAsLoaded();

            log.Performance("Loading database " + databaseDictionary.DatabaseName, analyzer.Result);
            analyzer.Stop();
        }
Ejemplo n.º 5
0
        private void StartBenchmark()
        {
            StartStopTestButton.Content = "Abort benchmark";

            OptionsGrid.Visibility   = Visibility.Collapsed;
            InfoTextBlock.Visibility = Visibility.Visible;

            _mouseCameraController.IsEnabled = false;

            _totalRenderTimes.Clear();

            _performanceAnalyzer = new PerformanceAnalyzer(_mainDXViewportView);


            // get only system info
            string systemInfo = _performanceAnalyzer.GetResultsText(addSystemInfo: true, addDXEngineInfo: true, addGarbageCollectionsInfo: false, addTotals: false, addStateChangesStatistics: false, addFirstFrameStatisticsWhenAvailable: false, addRenderingStatistics: false, addMultiThreadingStatistics: false);

            InfoTextBlock.Text = $"Starting benchmark ({_mainDXViewportView.PresentationType} with {_objectsCount} objects)\r\nwith changing MaxBackgroundThreadsCount from 0 to {ThreadsCountSlider.Maximum:0}.\r\n\r\n{systemInfo}\r\n====================\r\n\r\nRendering with MaxBackgroundThreadsCount = 0\r\n\r\n";
            InfoTextBlock.UpdateLayout();
            InfoTextBlock.ScrollToEnd();


            SetLightingMode(LightingMode.DirectionalLight);
            ThreadsCountSlider.Value = 0;

            _benchmarkResults          = new StringBuilder();
            _benchmarkTotalRenderTimes = new List <double>();

            _benchmarkStepFramesCount          = 1;
            _mainDXViewportView.SceneRendered += OnBenchmarkSceneRendered;
        }
Ejemplo n.º 6
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new MainForm());
     Console.WriteLine(PerformanceAnalyzer.GenerateReport("OnPaint"));
 }
        /// <summary>
        /// Executes the background action behind this item.
        /// </summary>
        public async Task Execute()
        {
            // Create PerformanceAnalyzer for kinect logic
            PerformanceAnalyzer performanceAnalyzer = new PerformanceAnalyzer(
                TimeSpan.FromMilliseconds(Constants.KINECT_PERF_VALUE_INTERVAL_MS),
                TimeSpan.FromMilliseconds(Constants.KINECT_PERF_CALC_INTERVAL_MS));
            performanceAnalyzer.GenerateCurrentValueCollection = true;
            performanceAnalyzer.GenerateHistoricalCollection = Constants.KINECT_PERF_HISTORICAL_VALUE_COUNT > 0;
            performanceAnalyzer.MaxCountHistoricalEntries = Constants.KINECT_PERF_HISTORICAL_VALUE_COUNT;
            performanceAnalyzer.RunAsync(CancellationToken.None)
                .FireAndForget();

            // Create and start the KinectHandler
            KinectThread kinectThread = new KinectThread(performanceAnalyzer);
            await kinectThread.StartAsync();

            // Register created objects
            SeeingSharpApplication.Current.RegisterSingleton(kinectThread);
            SeeingSharpApplication.Current.Singletons.RegisterSingleton(performanceAnalyzer, Constants.KINECT_PERF_ANALYZER_NAME);

            // Create other processing objects
            KinectRawStreamPresenter rawStreamProcessor = new KinectRawStreamPresenter();
            SeeingSharpApplication.Current.Singletons.RegisterSingleton(rawStreamProcessor);

            // Creates the main engagement model for this application
            HandOverheadEngagementModel customEngagementModel = new HandOverheadEngagementModel();
            SeeingSharpApplication.Current.RegisterService<IKinectEngagementManager>(customEngagementModel);
        }
Ejemplo n.º 8
0
        protected Size GetLabelSize(DrawContext context, string label)
        {
            PerformanceAnalyzer.Start("GetLabelSize");

            Font font = GetDrawingFont(context, label);
            Size s    = Size.Empty;

            if (!UseCompatibleTextRendering)
            {
                s = TextRenderer.MeasureText(label, font);
            }
            else
            {
                SizeF sf = context.Graphics.MeasureString(label, font);
                s = new Size((int)Math.Ceiling(sf.Width), (int)Math.Ceiling(sf.Height));
            }

            PerformanceAnalyzer.Finish("GetLabelSize");

            if (!s.IsEmpty)
            {
                return(s);
            }
            else
            {
                return(new Size(10, font.Height));
            }
        }
Ejemplo n.º 9
0
        void LoadObjects(Database d, IDatabaseDictionary databaseDictionary)
        {
            if (!d.IsSystemObject && d.IsAccessible)
            {
                try
                {
                    var analyzer = new PerformanceAnalyzer();

                    LoadTables(d, databaseDictionary);
                    log.Performance("Loading tables " + d.Name, analyzer.Result);

                    LoadStoredProcs(d, databaseDictionary);
                    log.Performance("Loading procedures " + d.Name, analyzer.Result);

                    LoadViews(d, databaseDictionary);
                    log.Performance("Loading views " + d.Name, analyzer.Result);

                    LoadFunctions(d, databaseDictionary);
                    log.Performance("Loading functions " + d.Name, analyzer.Result);

                    analyzer.Stop();
                }
                catch (Exception ex)
                {
                    // this can get thrown for security reasons - probably need to swallow here
                    log.Error("Security Error in database: " + d.Name, ex);
                }
            }
        }
Ejemplo n.º 10
0
		private void DrawColumnHeaders(Graphics gr)
		{
			PerformanceAnalyzer.Start("DrawColumnHeaders");
			ReorderColumnState reorder = Input as ReorderColumnState;
			int x = 0;
			TreeColumn.DrawBackground(gr, new Rectangle(0, 0, ClientRectangle.Width + 2, ColumnHeaderHeight - 1), false, false);
			gr.TranslateTransform(-OffsetX, 0);
			foreach (TreeColumn c in Columns)
			{
				if (c.IsVisible)
				{
					if (x >= OffsetX && x - OffsetX < this.Bounds.Width)// skip invisible columns
					{
						Rectangle rect = new Rectangle(x, 0, c.Width, ColumnHeaderHeight - 1);
						gr.SetClip(rect);
						bool pressed = ((Input is ClickColumnState || reorder != null) && ((Input as ColumnState).Column == c));
						c.Draw(gr, rect, Font, pressed, _hotColumn == c);
						gr.ResetClip();

						if (reorder != null && reorder.DropColumn == c)
							TreeColumn.DrawDropMark(gr, rect);
					}
					x += c.Width;
				}
			}

			if (reorder != null)
			{
				if (reorder.DropColumn == null)
					TreeColumn.DrawDropMark(gr, new Rectangle(x, 0, 0, ColumnHeaderHeight));
				gr.DrawImage(reorder.GhostImage, new Point(reorder.Location.X +  + reorder.DragOffset, reorder.Location.Y));
			}
			PerformanceAnalyzer.Finish("DrawColumnHeaders");
		}
Ejemplo n.º 11
0
        private UiHandler(UiReferenceContainer uiRefContainer)
        {
            _uiRefContainer = uiRefContainer;

            //MEMORY USAGE INFO HANDLING
            PerformanceAnalyzer.HandleMemoryUsageInfo memUsageMethodDelegate = new PerformanceAnalyzer.HandleMemoryUsageInfo(HandleMemoryUsageInfo);
            PerformanceAnalyzer.BeginAnalyzing(memUsageMethodDelegate);
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!this.DesignMode)
            {
                m_performanceAnalyzer = GraphicsCore.Current.PerformanceCalculator;
            }
        }
Ejemplo n.º 13
0
        private void txtSearch_TextChanged(Object sender, TextChangedEventArgs e)
        {
            log.Info(String.Format("Search text changed to '{0}'", txtSearch.Text));
            var analyzer = new PerformanceAnalyzer();

            DoSearch(false);

            log.Performance("Text changed event handled", analyzer.Result);
            analyzer.Stop();
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderState"/> class.
 /// </summary>
 internal RenderState(
     EngineDevice device,
     PerformanceAnalyzer performanceCalculator,
     RenderTargets renderTargets,
     SharpDX.Mathematics.Interop.RawViewportF viewport,
     Camera3DBase camera, ViewInformation viewInformation)
     : this(device, performanceCalculator)
 {
     Reset(renderTargets, viewport, camera, viewInformation);
 }
Ejemplo n.º 15
0
        public override void Draw(TreeNodeAdv node, DrawContext context)
        {
            if (context.CurrentEditorOwner == this &&
                node == Parent.CurrentNode &&
                !this.EditorDisposing)
            {
                return;
            }

            PerformanceAnalyzer.Start("BaseTextControl.Draw");
            string    label     = GetLabel(node);
            Rectangle bounds    = GetBounds(node, context);
            Rectangle focusRect = new Rectangle(bounds.X, context.Bounds.Y,
                                                bounds.Width, context.Bounds.Height);

            Brush backgroundBrush;
            Color textColor;
            Font  font;

            CreateBrushes(node, context, label, out backgroundBrush, out textColor, out font, ref label);

            if (backgroundBrush != null)
            {
                context.Graphics.FillRectangle(backgroundBrush, focusRect);
            }
            if (context.DrawFocus)
            {
                focusRect.Width--;
                focusRect.Height--;
                if (context.DrawSelection == DrawSelectionMode.None)
                {
                    _focusPen.Color = SystemColors.ControlText;
                }
                else
                {
                    _focusPen.Color = SystemColors.InactiveCaption;
                }
                context.Graphics.DrawRectangle(_focusPen, focusRect);
            }

            PerformanceAnalyzer.Start("BaseTextControl.DrawText");

            if (!UseCompatibleTextRendering)
            {
                TextRenderer.DrawText(context.Graphics, label, font, bounds, textColor, _formatFlags);
            }
            else
            {
                context.Graphics.DrawString(label, font, GetFrush(textColor), bounds, _format);
            }
            PerformanceAnalyzer.Finish("BaseTextControl.DrawText");

            PerformanceAnalyzer.Finish("BaseTextControl.Draw");
        }
Ejemplo n.º 16
0
        public override void Draw(TreeNodeAdv node, DrawContext context)
        {
            if (context.CurrentEditorOwner == this && node == Parent.CurrentNode)
            {
                return;
            }

            PerformanceAnalyzer.Start("BaseTextControl.Draw");

            Rectangle bounds    = GetBounds(node, context);
            Rectangle focusRect = new Rectangle(bounds.X, context.Bounds.Y,
                                                bounds.Width, context.Bounds.Height);

            DrawEventArgs args;

            CreateBrushes(node, context, out args);

            if (args.BackgroundBrush != null)
            {
                context.Graphics.FillRectangle(args.BackgroundBrush, focusRect);
            }
            if (context.DrawFocus)
            {
                focusRect.Width--;
                focusRect.Height--;
                if (context.DrawSelection == DrawSelectionMode.None)
                {
                    _focusPen.Color = SystemColors.ControlText;
                }
                else
                {
                    _focusPen.Color = SystemColors.InactiveCaption;
                }
                context.Graphics.DrawRectangle(_focusPen, focusRect);
            }

            PerformanceAnalyzer.Start("BaseTextControl.DrawText");

            DrawHighLight(context, bounds, args);

            if (!UseCompatibleTextRendering)
            {
                TextRenderer.DrawText(context.Graphics, args.Text, args.Font, bounds, args.TextColor, _formatFlags);
            }
            else
            {
                context.Graphics.DrawString(args.Text, args.Font, GetFrush(args.TextColor), bounds, _format);
            }


            PerformanceAnalyzer.Finish("BaseTextControl.DrawText");
            PerformanceAnalyzer.Finish("BaseTextControl.Draw");
        }
Ejemplo n.º 17
0
        protected override void OnPaint(PaintEventArgs e)
        {
            BeginPerformanceCount();
			PerformanceAnalyzer.Start("OnPaint");

            DrawContext context = new DrawContext();
            context.Graphics = e.Graphics;
            context.Font = this.Font;
            context.Enabled = Enabled;

            int y = 0;
            int gridHeight = 0;

            if (UseColumns)
            {
				DrawColumnHeaders(e.Graphics);
				y += ColumnHeaderHeight;
                if (Columns.Count == 0 || e.ClipRectangle.Height <= y)
                    return;
            }

			int firstRowY = _rowLayout.GetRowBounds(FirstVisibleRow).Y;
            y -= firstRowY;

            e.Graphics.ResetTransform();
            e.Graphics.TranslateTransform(-OffsetX, y);
            Rectangle displayRect = DisplayRectangle;
            for (int row = FirstVisibleRow; row < RowCount; row++)
            {
                Rectangle rowRect = _rowLayout.GetRowBounds(row);
                gridHeight += rowRect.Height;
                if (rowRect.Y + y > displayRect.Bottom)
                    break;
                else
                    DrawRow(e, ref context, row, rowRect);
            }

			if ((GridLineStyle & GridLineStyle.Vertical) == GridLineStyle.Vertical && UseColumns)
				DrawVerticalGridLines(e.Graphics, firstRowY);

			if (_dropPosition.Node != null && DragMode && HighlightDropPosition)
                DrawDropMark(e.Graphics);

            e.Graphics.ResetTransform();
            DrawScrollBarsBox(e.Graphics);

            if (DragMode && _dragBitmap != null)
                e.Graphics.DrawImage(_dragBitmap, PointToClient(MousePosition));

			PerformanceAnalyzer.Finish("OnPaint");
			EndPerformanceCount(e);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KinectHandler"/> class.
        /// </summary>
        /// <param name="Messenger">The Messenger which is used for thread- und component-synchronization.</param>
        /// <param name="performanceAnalyzer">The PerformanceAnalyzer which tracks the kinect's performance values.</param>
        public KinectHandler(
            SeeingSharpMessenger Messenger,
            PerformanceAnalyzer performanceAnalyzer)
        {
            if (!SeeingSharpApplication.IsInitialized) { return; }

            m_Messenger = Messenger;
            m_performanceAnalyzer = performanceAnalyzer;

            m_sensor = KinectSensor.GetDefault();
            if (m_sensor == null) { return; }

            m_sensor.IsAvailableChanged += OnSensor_IsAvailableChanged;
            m_sensor.Open();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderState"/> class.
        /// </summary>
        /// <param name="device">The device object.</param>
        /// <param name="performanceCalculator">The object used to calculate performance values</param>
        private RenderState(EngineDevice device, PerformanceAnalyzer performanceCalculator)
        {
            //Set device members
            m_device         = device;
            this.DeviceIndex = device.DeviceIndex;

            //Initialize world matrix
            m_world = new Matrix4Stack(Matrix4x4.Identity);

            //Create settings stack
            m_renderSettingsStack = new Stack <RenderStackEntry>();
            m_sceneStack          = new Stack <Tuple <Core.Scene, ResourceDictionary> >();

            m_perfomanceCalculator = performanceCalculator;
        }
        public PerformanceTest()
        {
            InitializeComponent();

            // To use RenderAsManyFramesAsPossible we need DirectXOverlay presentation type
            MainDXViewportView.PresentationType = DXView.PresentationTypes.DirectXOverlay;

            InfoTextBlock.Text = string.Format(InfoTextBlock.Text, HeadingIncreaseOnEachFrame);

            MainDXViewportView.DXSceneInitialized += delegate(object sender, EventArgs args)
            {
                if (MainDXViewportView.DXScene == null) // Probably WPF 3D rendering
                {
                    return;
                }

                string testName = string.Format("PerformanceTest with '{0}' ({1})",
                                                System.IO.Path.GetFileName(StartupFileName),
                                                OptimizeReadModel ? "optimized" : "not optimized");

                _performanceAnalyzer = new PerformanceAnalyzer(MainDXViewportView, testName, initialCapacity: 10000);
                _performanceAnalyzer.StartCollectingStatistics();
            };


            this.Loaded += OnLoaded;


            //this.Focusable = true; // by default Page is not focusable and therefore does not receive keyDown event
            //this.PreviewKeyDown += OnPreviewKeyDown;


            // FPS will be displayed in Window Title - save the title so we can restore it later
            _savedWindowTitle = Application.Current.MainWindow.Title;

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                StopTest(showResults: false);

                MainDXViewportView.Dispose();

                if (_parentWindow != null)
                {
                    _parentWindow.PreviewKeyDown -= OnPreviewKeyDown;
                }
            };
        }
Ejemplo n.º 21
0
        public void Run()
        {
            while (true)
            {
                var i = WaitHandle.WaitAny(new WaitHandle[] { stop, doWork });

                if (i == 0)
                {
                    break;
                }

                var processRequest = true;

                while (processRequest)
                {
                    var request = GetRequest();

                    if (request != null)
                    {
                        try
                        {
                            log.Info(String.Format("Processing request: type = {0}, parameter = {{ {1} }}", request.RequestType.ToString(), request.Argument));
                            var analyzer = new PerformanceAnalyzer();

                            request.DoWorkFunction(request.Argument);

                            analyzer.Stop();
                            log.Performance("Request process time", analyzer.Result);
                        }
                        catch (Exception ex)
                        {
                            if (RequestFailed != null)
                            {
                                RequestFailed.Invoke(request, ex);
                            }
                        }
                    }
                    else
                    {
                        processRequest = false;
                    }
                }
            }
        }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            Console.WriteLine(string.Join(" ", ArrayGenerator.Generate(10, false, 1, 11)));

            Console.WriteLine();

            var array = ArrayGenerator.Generate(10, true, 1, 151);

            Console.WriteLine(string.Join(" ", array));

            var result = new int[0];
            var ticks  = 0L;

            array = new[] { 5, 4, 3, 2, 1, 6, 6, 7, 2, 8, 9, 3 };

//            var time = PerformanceAnalyzer.GetExecutionTime(() => result = new Bogosort<int>().SortDebug(array, ListSortDirection.Ascending, out ticks));

//            Console.WriteLine($"Random sort:\n{string.Join(" ", result)} for {time.Milliseconds} ms; {ticks} iterations");

//            var time = PerformanceAnalyzer.GetExecutionTime(() => result = new BruteForceSort<int>().SortDebug(array, ListSortDirection.Ascending, out ticks));

//            Console.WriteLine($"Brute force sort:\n{string.Join(" ", result)} for {time.Milliseconds} ms; {ticks} iterations");

            var time = PerformanceAnalyzer.GetExecutionTime(() => result = new PancakeSort <int>().Sort(array, ListSortDirection.Ascending));

            Console.WriteLine($"Brute force sort:\n{string.Join(" ", result)} for {time.Milliseconds} ms; {ticks} iterations");

            /*var busted = new int[array.Length];
             *
             * var count = 0;
             *
             * Bust(busted, array, 0, ref count);*/

//            Console.WriteLine($"Total combinations: {count}");

/*              array.Shuffle();
 *          Console.WriteLine(string.Join(" ", array));
 *
 *          array.Shuffle(1);
 *          Console.WriteLine(string.Join(" ", array));*/

            Console.ReadLine();
        }
Ejemplo n.º 23
0
        private void DisplayResultItem(Item resultItem)
        {
            var analyzer = new PerformanceAnalyzer();

            Inlines.Clear();
            runs.Clear();

            if ((resultItem.Keywords == null) || resultItem.Keywords.IsEmpty())
            {
                // TODO: get rid of code duplication (lines 89, 106, 116)
                var run = new Run(resultItem.Name);
                Inlines.Add(run);
            }
            else
            {
                try
                {
                    var ranges = FindMatchingKeyworkRanges(resultItem);

                    if (ranges.Any())
                    {
                        var mergedResult = Range <Int32> .Merge(ranges);

                        BuildRunsFromMergedResults(resultItem, mergedResult);
                    }
                    else
                    {
                        // TODO: get rid of code duplication (lines 89, 106, 116)
                        var run = new Run(resultItem.Name);
                        Inlines.Add(run);
                    }
                }
                // TODO: What is it for? How can any exception happen here?
                catch (Exception ex)
                {
                    log.Error(ex.Message, ex);

                    // TODO: get rid of code duplication (lines 89, 106, 116)
                    var run = new Run(resultItem.Name);
                    Inlines.Add(run);
                }
            }
        }
Ejemplo n.º 24
0
        private void StopBenchmark()
        {
            _performanceAnalyzer        = null; // This will also signal that we are not executing the benchmark any more
            StartStopTestButton.Content = "Hide results";

            _mouseCameraController.IsEnabled = true;

            _mainDXViewportView.SceneRendered -= OnBenchmarkSceneRendered;


            _framesCount = 0;
            _drawRenderTimes.Clear();
            _completeRenderTimes.Clear();
            _totalRenderTimes.Clear();


            // Show results:
            AddInfoText("\r\nBenchmark completed\r\n");

            if (_benchmarkResults != null && _benchmarkTotalRenderTimes.Count > 1)
            {
                AddInfoText("PERFORMANCE SUMMARY:");
                AddInfoText("Background threads count and total render time:");

                for (int i = 0; i < _benchmarkTotalRenderTimes.Count; i++)
                {
                    string infoText = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0,2}  {1,5:0.00} ms", i, _benchmarkTotalRenderTimes[i]);

                    if (i > 0)
                    {
                        infoText += string.Format(System.Globalization.CultureInfo.InvariantCulture, " ({0:0.00} times faster)", _benchmarkTotalRenderTimes[0] / _benchmarkTotalRenderTimes[i]);
                    }

                    AddInfoText(infoText);
                }
            }
        }
Ejemplo n.º 25
0
 public PerformanceOverviewViewModel(PerformanceAnalyzer performanceAnalyzer)
 {
     _performanceAnalyzer = performanceAnalyzer;
     this.DurationResults = new List <DurationPerformanceResult>();
 }
Ejemplo n.º 26
0
        private void Async_PerformSearch(Object arg)
        {
            if (arg == null)
            {
                return;
            }

            var par = (SearchAsyncParam)arg;

            // new request was added - this one is outdated
            if (par.SequenceNumber < _requestSequenceNumber)
            {
                return;
            }

            if (SameAsPreviousSearch(par))
            {
                return;
            }

            SetStatus("Searching '" + par.Text + "' in " + par.Database, true);

            var result = StudioController.Find(par.Srv, par.Database, par.Text, _cfg.LimitSearch);

            // new request was added - this one is outdated
            if (par.SequenceNumber < _requestSequenceNumber)
            {
                log.Info("Cancelled search request because new request was added. " + par.Text);
                return;
            }

            SetStatus("Found " + result.Count + " objects");

            InvokeInUI(() =>
            {
                log.Info("Updating UI items");
                var analyzer = new PerformanceAnalyzer();

                var items = ItemFactory.BuildFromEntries(result);

                itemsControl.ItemsSource   = items;
                itemsControl.SelectedIndex = -1;
                itemsControl.ScrollIntoView(itemsControl.SelectedItem);

                if (items.Count == 0)
                {
                    gridEmptyResult.Visibility = System.Windows.Visibility.Visible;
                    itemsControl.Visibility    = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    gridEmptyResult.Visibility = System.Windows.Visibility.Collapsed;
                    itemsControl.Visibility    = System.Windows.Visibility.Visible;
                }

                log.Performance("UI items updated", analyzer.Result);
                analyzer.Stop();
            });

            if (result.Count == 0)
            {
                SetStatus("Found nothing. Try to refresh");
            }
            else if (result.Count == 1)
            {
                SetStatus("Found exactly one object");
            }
            else
            {
                SetStatus("Found " + result.Count + " objects ");
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsCore"/> class.
        /// </summary>
        protected GraphicsCore(bool debugEnabled, bool force2DFallback)
        {
            try
            {
                // Upate RK.Common members
                m_debugEnabled                      = debugEnabled;
                m_force2DFallback                   = force2DFallback;
                m_devices                           = new List <EngineDevice>();
                m_performanceCalculator             = new PerformanceAnalyzer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(2.0));
                m_performanceCalculator.SyncContext = SynchronizationContext.Current; // <-- TODO
                m_performanceCalculator.RunAsync(CancellationToken.None)
                .FireAndForget();

                m_configuration = new GraphicsCoreConfiguration();
                m_configuration.DebugEnabled = debugEnabled;

                // Create container object for all input handlers
                m_inputHandlerFactory = new InputHandlerFactory();
                m_importExporters     = new ImporterExporterRepository();

                // Create the key generator for resource keys
                m_resourceKeyGenerator = new UniqueGenericKeyGenerator();

                // Try to initialize global api factories (mostly for 2D rendering / operations)
                try
                {
                    if (s_throwDeviceInitError)
                    {
                        throw new SeeingSharpException("Simulated device initialization exception");
                    }

                    m_factoryHandlerWIC     = new FactoryHandlerWIC();
                    m_factoryHandlerD2D     = new FactoryHandlerD2D(this);
                    m_factoryHandlerDWrite  = new FactoryHandlerDWrite(this);
                    m_factoryHandlerXAudio2 = new FactoryHandlerXAudio2();
                }
                catch (Exception ex)
                {
                    m_initException = ex;

                    m_devices.Clear();
                    m_factoryHandlerWIC     = null;
                    m_factoryHandlerD2D     = null;
                    m_factoryHandlerDWrite  = null;
                    m_factoryHandlerXAudio2 = null;
                    return;
                }
                this.FactoryD2D    = m_factoryHandlerD2D.Factory;
                this.FactoryD2D_2  = m_factoryHandlerD2D.Factory2;
                this.FactoryDWrite = m_factoryHandlerDWrite.Factory;
                this.FactoryWIC    = m_factoryHandlerWIC.Factory;
                this.XAudioDevice  = m_factoryHandlerXAudio2.Device;

                // Create the SoundManager
                m_soundManager = new SoundManager(m_factoryHandlerXAudio2);

                // Try to initialize Media Foundation interface
                // (This is a separated init step because MF may not be available on some systems, e. g. Servers)
                try
                {
                    m_factoryHandlerMF = new FactoryHandlerMF();
                }
                catch (Exception)
                {
                    m_factoryHandlerMF = null;
                }

                // Create the object containing all hardware information
                m_hardwareInfo = new EngineHardwareInfo();
                int actIndex = 0;
                foreach (var actAdapterInfo in m_hardwareInfo.Adapters)
                {
                    EngineDevice actEngineDevice = new EngineDevice(
                        this,
                        m_configuration,
                        actAdapterInfo.Adapter,
                        actAdapterInfo.IsSoftwareAdapter,
                        debugEnabled);
                    if (actEngineDevice.IsLoadedSuccessfully)
                    {
                        actEngineDevice.DeviceIndex = actIndex;
                        actIndex++;

                        m_devices.Add(actEngineDevice);
                    }
                }
                m_defaultDevice = m_devices.FirstOrDefault();

                // Start input gathering
                m_inputGatherer = new InputGathererThread();
                m_inputGatherer.Start();

                // Start main loop
                m_mainLoop = new EngineMainLoop(this);
                if (m_devices.Count > 0)
                {
                    m_mainLoopCancelTokenSource = new CancellationTokenSource();
                    m_mainLoopTask = m_mainLoop.Start(m_mainLoopCancelTokenSource.Token);
                }
            }
            catch (Exception ex2)
            {
                m_initException = ex2;

                m_hardwareInfo = null;
                m_devices.Clear();
                m_configuration        = null;
                m_resourceKeyGenerator = null;
            }
        }
Ejemplo n.º 28
0
 public void Dispose()
 {
     PerformanceAnalyzer.StopAnalyzing();
 }