|
|
|
@ -1,8 +1,10 @@
@@ -1,8 +1,10 @@
|
|
|
|
|
using ICSharpCode.Profiler.AddIn.OptionsPanels; |
|
|
|
|
using System; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.Globalization; |
|
|
|
|
using System.IO; |
|
|
|
|
|
|
|
|
|
using ICSharpCode.Core; |
|
|
|
|
using ICSharpCode.Profiler.AddIn.OptionsPanels; |
|
|
|
|
using ICSharpCode.Profiler.Controller; |
|
|
|
|
using ICSharpCode.Profiler.Controller.Data; |
|
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
|
@ -17,33 +19,43 @@ namespace ICSharpCode.Profiler.AddIn
@@ -17,33 +19,43 @@ namespace ICSharpCode.Profiler.AddIn
|
|
|
|
|
{ |
|
|
|
|
public static Profiler.Controller.Profiler RunCurrentProject(out string profilerSessionFilePath) |
|
|
|
|
{ |
|
|
|
|
profilerSessionFilePath = Path.Combine(ProjectService.CurrentProject.Directory, @"ProfilingSessions\Session" + DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + ".sdps"); |
|
|
|
|
AbstractProject currentProj = ProjectService.CurrentProject as AbstractProject; |
|
|
|
|
|
|
|
|
|
profilerSessionFilePath = Path.Combine(currentProj.Directory, @"ProfilingSessions\Session" + DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture) + ".sdps"); |
|
|
|
|
|
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(profilerSessionFilePath)); |
|
|
|
|
|
|
|
|
|
if (!ProjectService.CurrentProject.IsStartable) { |
|
|
|
|
if (currentProj == null) |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
if (!currentProj.IsStartable) { |
|
|
|
|
MessageService.ShowError("This project cannot be started, please select a startable project for Profiling!"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
if (!File.Exists(ProjectService.CurrentProject.OutputAssemblyFullPath)) { |
|
|
|
|
if (!File.Exists(currentProj.OutputAssemblyFullPath)) { |
|
|
|
|
MessageService.ShowError("This project cannot be started because the executable file was not found, " + |
|
|
|
|
"please ensure that the project and all its depencies are built correctly!"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Profiler.Controller.Profiler profiler = InitProfiler(ProjectService.CurrentProject.OutputAssemblyFullPath, profilerSessionFilePath); |
|
|
|
|
Profiler.Controller.Profiler profiler = InitProfiler(currentProj.CreateStartInfo(), profilerSessionFilePath); |
|
|
|
|
profiler.ProfilerOptions = ProfilerOptionsWrapper.CreateProfilerOptions(); |
|
|
|
|
profiler.Start(); |
|
|
|
|
|
|
|
|
|
return profiler; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Profiler.Controller.Profiler InitProfiler(string path, string outputFilePath) |
|
|
|
|
{ |
|
|
|
|
Profiler.Controller.Profiler profiler = new Profiler.Controller.Profiler(path, new ProfilingDataSQLiteWriter(outputFilePath)); |
|
|
|
|
return InitProfiler(new ProcessStartInfo(path), outputFilePath); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static Profiler.Controller.Profiler InitProfiler(ProcessStartInfo startInfo, string outputFilePath) |
|
|
|
|
{ |
|
|
|
|
Profiler.Controller.Profiler profiler = new Profiler.Controller.Profiler(startInfo, new ProfilingDataSQLiteWriter(outputFilePath)); |
|
|
|
|
|
|
|
|
|
profiler.RegisterFailed += delegate { MessageService.ShowError("regsvr32 failed"); }; |
|
|
|
|
profiler.DeregisterFailed += delegate { MessageService.ShowError("regsvr32 /u failed"); }; |
|
|
|
|
profiler.RegisterFailed += delegate { MessageService.ShowError("Could not register the profiler into COM Registry. Cannot start profiling!"); }; |
|
|
|
|
profiler.DeregisterFailed += delegate { MessageService.ShowError("Could not unregister the profiler from COM Registry!"); }; |
|
|
|
|
profiler.OutputUpdated += delegate { SetOutputText(profiler.ProfilerOutput); }; |
|
|
|
|
|
|
|
|
|
return profiler; |
|
|
|
|