예제 #1
0
        public ProfileSession CreateSession(SDBDeviceInfo device, ProfileSessionConfiguration sessionConfiguration,
                                            bool isLiveProfiling)
        {
            string details;

            if (ProfilerPlugin.Instance.BuildSolution())
            {
                try
                {
                    return(new ProfileSession(device, sessionConfiguration, isLiveProfiling));
                }
                catch (Exception ex)
                {
                    details = ex.Message;
                }
            }
            else
            {
                details = "Solution build failed";
            }
            string errMsg = $"Cannot start profiling session. {details}";

            ProfilerPlugin.Instance.WriteToOutput(errMsg);
            ProfilerPlugin.Instance.ShowError(errMsg);
            return(null);
        }
        public RunProfilerDialog(ProfileSessionConfiguration sessionConfiguration)
        {
            CurrentConfiguration = sessionConfiguration;

            Owner = Application.Current.MainWindow;

            DataContext = this;
            InitializeComponent();
        }
예제 #3
0
        /// <summary>
        /// Start a profiling session.
        /// </summary>
        /// <remarks>
        /// A run profiler dialog is shown (if not starting a live profiling session). The dialog allows a user to edit
        /// different profiling options.
        /// </remarks>
        /// <param name="isLiveProfiling">
        /// true in case of live profiling (i.e. combined debugging and profiling), false otherwise
        /// </param>
        /// <returns>true if profiling has been started successfully, false otherwise</returns>
        public bool StartProfiler(bool isLiveProfiling)
        {
            Project project;

            if (!CanStartProfiler(out project) || (project == null))
            {
                return(false);
            }

            var sessionConfiguration = new ProfileSessionConfiguration(project, GeneralOptions);

            if (isLiveProfiling)
            {
                var preset = ProfilingPreset.CpuSampling;
                preset.ProfilingSettings.TraceSourceLines = false; // TODO!! example
                sessionConfiguration.ProfilingPreset      = preset;
            }
            else
            {
                var dlg = new RunProfilerDialog(sessionConfiguration);
                dlg.ShowDialog();
                if (!(dlg.DialogResult ?? false))
                {
                    return(false);
                }
            }

            SDBDeviceInfo device = GetAndCheckSelectedDevice(isLiveProfiling ? RunMode.LiveProfiler : RunMode.CoreProfiler);

            if (device == null)
            {
                return(false);
            }

            ProfileSession session = ProfileLauncher.CreateSession(device, sessionConfiguration, isLiveProfiling);

            if (session == null)
            {
                return(false);
            }
            ProfilingProgressWindow.SetSession(session);
            ProfileLauncher.StartSession(session);
            return(true);
        }