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()); } } ) ); }
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); }
/// <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; }
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); }
public ProfilerView(ProfilingDataProvider provider) { InitializeComponent(); this.provider = provider; this.timeLine.IsEnabled = true; this.timeLine.ValuesList.Clear(); this.timeLine.ValuesList.AddRange(this.provider.DataSets.Select(i => new TimeLineInfo() { value = i.CpuUsage / 100, displayMarker = i.IsFirst })); this.timeLine.SelectedStartIndex = 0; this.timeLine.SelectedEndIndex = this.timeLine.ValuesList.Count; 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.CreateContextMenu(source, "/AddIns/Profiler/QueryView/ContextMenu").IsOpen = true; }; } } 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(); }
void LoadData() { AdornerLayer layer = AdornerLayer.GetAdornerLayer(this); OverlayAdorner ad = new OverlayAdorner(this); WaitBar bar = new WaitBar(Translation.WaitBarText); ad.Child = bar; layer.Add(ad); int rangeStart = RangeStart; int rangeEnd = RangeEnd; string query = this.CurrentQuery; ProfilingDataProvider provider = Provider; QueryCompiler compiler = new QueryCompiler(Reporter, query); ringDiagram.SelectedRoot = null; task.Execute(() => LoadWorker(provider, compiler, rangeStart, rangeEnd), list => LoadCompleted(list, layer, ad), delegate { layer.Remove(ad); }); }
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)); }
private void InitializeDataProvider(ProgressMonitor progressMonitor, DateTime sysInfoStartTime, int cpuCoreCount) { _dataContainer = new DataContainer(GetProfilerDataFileName(), cpuCoreCount); DateTime profilerStartTime; _dataContainer.Load(progressMonitor, sysInfoStartTime, out profilerStartTime); if (profilerStartTime == DateTime.MinValue) { throw new Exception("Invalid session log"); } /* * DateTime startTime = profilerStartTime; * if ((sysInfoStartTime != DateTime.MinValue) && (sysInfoStartTime < startTime)) * { * startTime = sysInfoStartTime; * } * // Subtract doesn't care of DateTime.Kind which is exactly what we want here * StartNanoseconds = (ulong)(Math.Round(startTime.Subtract(TimeStampHelper.UnixEpochTime).TotalMilliseconds)) * 1000000; */ _profilingDataProvider = new ProfilingDataProvider(_dataContainer, () => new CallStatisticsTreeNode()); }
/// <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()); } }
/// <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; } ); }