internal SessionNode OpenTarget(ProfilingTarget target, string filename) { for (int i = 0; i < _sessions.Count; i++) { if (_sessions[i].Filename == filename) { throw new InvalidOperationException(Strings.PerformanceSessionAlreadyOpen.FormatUI(filename)); } } uint prevSibl; if (_sessions.Count > 0) { prevSibl = _sessions[_sessions.Count - 1].ItemId; } else { prevSibl = VSConstants.VSITEMID_NIL; } var node = new SessionNode(_serviceProvider, this, target, filename); _sessions.Add(node); OnItemAdded(VSConstants.VSITEMID_ROOT, prevSibl, node.ItemId); if (_activeSession == VSConstants.VSITEMID_NIL) { SetActiveSession(node); } return(node); }
public IPythonProfileSession LaunchProject(EnvDTE.Project projectToProfile, bool openReport) { var target = new ProfilingTarget(); target.ProjectTarget = new ProjectTarget(); target.ProjectTarget.TargetProject = new Guid(projectToProfile.Properties.Item("Guid").Value as string); target.ProjectTarget.FriendlyName = projectToProfile.Name; return(PythonProfilingPackage.Instance.ProfileTarget(target, openReport).GetAutomationObject()); }
internal SessionNode AddTarget(ProfilingTarget target, string filename, bool save) { Debug.Assert(filename.EndsWithOrdinal(".pyperf", ignoreCase: true)); // ensure a unique name string newBaseName = Path.GetFileNameWithoutExtension(filename); string tempBaseName = newBaseName; int append = 0; bool dupFound; do { dupFound = false; for (int i = 0; i < _sessions.Count; i++) { if (Path.GetFileNameWithoutExtension(_sessions[i].Filename) == newBaseName) { dupFound = true; } } if (dupFound) { append++; newBaseName = tempBaseName + append; } } while (dupFound); string newFilename = newBaseName + ".pyperf"; // add directory name back if present... string dirName = Path.GetDirectoryName(filename); if (!string.IsNullOrEmpty(dirName)) { newFilename = Path.Combine(dirName, newFilename); } filename = newFilename; // save to the unique item if desired (we save whenever we have an active solution as we have a place to put it)... if (save) { using (var fs = new FileStream(filename, FileMode.Create)) { ProfilingTarget.Serializer.Serialize(fs, target); } } var node = OpenTarget(target, filename); if (!save) { node.MarkDirty(); node._neverSaved = true; } return(node); }
internal static bool IsSame(ProfilingTarget self, ProfilingTarget other) { if (self == null) { return(other == null); } else if (other != null) { return(ProjectTarget.IsSame(self.ProjectTarget, other.ProjectTarget) && StandaloneTarget.IsSame(self.StandaloneTarget, other.StandaloneTarget)); } return(false); }
/// <summary> /// Create a ProfilingTargetView with values taken from a template. /// </summary> public ProfilingTargetView(IServiceProvider serviceProvider, ProfilingTarget template) : this(serviceProvider) { if (template.ProjectTarget != null) { Project = new ProjectTargetView(template.ProjectTarget); IsStandaloneSelected = false; IsProjectSelected = true; } else if (template.StandaloneTarget != null) { Standalone = new StandaloneTargetView(serviceProvider, template.StandaloneTarget); IsProjectSelected = false; IsStandaloneSelected = true; } _startText = Strings.LaunchProfiling_OK; }
public IPythonProfileSession LaunchProcess(string interpreter, string script, string workingDir, string arguments, bool openReport) { var target = new ProfilingTarget(); target.StandaloneTarget = new StandaloneTarget(); target.StandaloneTarget.WorkingDirectory = workingDir; target.StandaloneTarget.Script = script; target.StandaloneTarget.Arguments = arguments; if (File.Exists(interpreter)) { target.StandaloneTarget.InterpreterPath = interpreter; } else { target.StandaloneTarget.PythonInterpreter = new PythonInterpreter(); target.StandaloneTarget.PythonInterpreter.Id = interpreter; } return(PythonProfilingPackage.Instance.ProfileTarget(target, openReport).GetAutomationObject()); }
internal ProfilingTarget Clone() { var res = new ProfilingTarget(); if (ProjectTarget != null) { res.ProjectTarget = ProjectTarget.Clone(); } if (StandaloneTarget != null) { res.StandaloneTarget = StandaloneTarget.Clone(); } if (Reports != null) { res.Reports = Reports.Clone(); } res.UseVTune = UseVTune; return(res); }