public ProfilerView(ProfilingDataProvider provider) { InitializeComponent(); this.provider = provider; this.timeLine.IsEnabled = true; this.timeLine.Provider = provider; this.timeLine.SelectedStartIndex = 0; this.timeLine.SelectedEndIndex = provider.DataSets.Count - 1; var translation = new SharpDevelopTranslation(); foreach (TabItem item in this.tabView.Items) { if (item.Content != null) { QueryView view = item.Content as QueryView; view.Reporter = new ErrorReporter(UpdateErrorList); view.Provider = provider; view.Translation = translation; view.SetRange(this.timeLine.SelectedStartIndex, this.timeLine.SelectedEndIndex); view.ContextMenuOpening += delegate(object sender, ContextMenuEventArgs e) { object source = (e.OriginalSource is Shape) ? e.OriginalSource : view; MenuService.ShowContextMenu(view, source, "/AddIns/Profiler/QueryView/ContextMenu"); }; } } this.dummyTab.Header = new Image { Source = PresentationResourceService.GetImage("Icons.16x16.NewDocumentIcon").Source, Height = 16, Width = 16 }; this.CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, ExecuteSelectAll, CanExecuteSelectAll)); InitializeLastItems(); InitializeOldTabs(); }
/// <summary> /// Creates a new WpfViewer object /// </summary> public WpfViewer(OpenedFile file, ProfilingDataSQLiteProvider provider) { // HACK : OpenedFile architecture does not allow to keep files open // but it is necessary for the ProfilerView to keep the session file open. // We don't want to load all session data into memory. // this.Files.Add(file); this.file = file; this.provider = provider; this.TabPageText = Path.GetFileName(file.FileName); this.TitleName = this.TabPageText; dataView = new ProfilerView(this.provider); // HACK : The file is not recognised by the FileService for closing if it is deleted while open. // (reason see above comment) FileService.FileRemoving += FileServiceFileRemoving; }
/// <summary> /// Creates a new WpfViewer object /// </summary> public WpfViewer(OpenedFile file) { // HACK : OpenedFile architecture does not allow to keep files open // but it is necessary for the ProfilerView to keep the session file open. // We don't want to load all session data into memory. // this.Files.Add(file); // HACK : The file is not recognised by the FileService for closing if it is deleted while open. // (reason see above comment) FileService.FileRemoving += FileServiceFileRemoving; this.file = file; this.provider = ProfilingDataSQLiteProvider.FromFile(file.FileName); this.TabPageText = Path.GetFileName(file.FileName); this.TitleName = this.TabPageText; this.host = new SharpDevelopElementHost(dataView = new ProfilerView(this.provider)); // HACK : Make host.Child visible WorkbenchSingleton.SafeThreadAsyncCall( () => { this.host.Dock = DockStyle.None; this.host.Dock = DockStyle.Fill; } ); }
static HierarchyList<CallTreeNodeViewModel> LoadWorker(ProfilingDataProvider provider, QueryCompiler compiler, int rangeStart, int rangeEnd) { try { if (compiler.Compile()) { IEnumerable<CallTreeNode> data = compiler.ExecuteQuery(provider, rangeStart, rangeEnd); #if DEBUG data = data.WithQueryLog(Console.Out); #endif var nodes = data.Select(i => new CallTreeNodeViewModel(i, null)).ToList(); return new HierarchyList<CallTreeNodeViewModel>(nodes); } } catch (ObjectDisposedException) { return null; } return null; }
void profiler_SessionEnded(object sender, EventArgs e) { string pathToDb = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(typeof(Profiler.Controller.Profiler).Assembly.Location), "output.sdps"); ProfilingDataSQLiteWriter writer = new ProfilingDataSQLiteWriter(pathToDb, false, null); this.database.WriteTo(writer, progress => true); writer.Close(); this.database.Close(); this.provider = new ProfilingDataSQLiteProvider(pathToDb); this.Dispatcher.Invoke( (Action)( () => { try { this.treeView.Provider = this.provider; RefreshUI(0, 0); this.timeLine.IsEnabled = true; //this.timeLine.ValuesList.Clear(); //this.timeLine.ValuesList.AddRange(this.provider.DataSets.Select(i => i.CpuUsage)); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); MessageBox.Show(ex.ToString()); } } ) ); }
private void btnLoadSession_Click(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "SharpDevelop Profiling Session|*.sdps|All files|*.*"; dlg.DefaultExt = ".sdps"; if (!(dlg.ShowDialog() ?? false)) return; if (this.provider != null) this.provider.Close(); this.provider = ProfilingDataSQLiteProvider.FromFile(dlg.FileName); this.treeView.Provider = this.provider; this.treeView.CurrentQuery = "from t in Threads select t"; treeView.SetRange(0, this.provider.DataSets.Count); this.timeLine.IsEnabled = true; //this.timeLine.ValuesList.Clear(); //this.timeLine.ValuesList.AddRange(provider.DataSets.Select(i => i.CpuUsage)); }
/// <summary> /// Executes the query. /// </summary> /// <returns>The result of the query.</returns> public IEnumerable<CallTreeNode> ExecuteQuery(ProfilingDataProvider provider, int startIndex, int endIndex) { if (provider == null) throw new ArgumentNullException("provider"); Assembly assembly; lock (queryCache) assembly = queryCache[this.currentQuery]; QueryBase queryContainer = assembly.CreateInstance("Query") as QueryBase; queryContainer.Provider = provider; queryContainer.StartDataSetIndex = startIndex; queryContainer.EndDataSetIndex = endIndex; queryContainer.Root = provider.GetRoot(startIndex, endIndex); object data = queryContainer.Execute(); if (data == null) return new List<CallTreeNode>().AsEnumerable(); if (data is CallTreeNode) { return (new CallTreeNode[] { data as CallTreeNode }).AsEnumerable(); } else if (data is IEnumerable<CallTreeNode>) { return (data as IEnumerable<CallTreeNode>); } else { throw new ProfilerException("Wrong query return type: " + data.GetType()); } }
static HierarchyList<CallTreeNodeViewModel> LoadWorker(ProfilingDataProvider provider, QueryCompiler compiler, int rangeStart, int rangeEnd) { try { if (compiler.Compile()) { var data = compiler.ExecuteQuery(provider, rangeStart, rangeEnd); var nodes = data.Select(i => new CallTreeNodeViewModel(i, null)).ToList(); return new HierarchyList<CallTreeNodeViewModel>(nodes); } } catch (ObjectDisposedException) { return null; } return null; }