internal void StartProfiling(ProfilingTarget target, SessionNode session, bool openReport = true)
        {
            if (!Utilities.SaveDirtyFiles())
            {
                // Abort
                return;
            }

            if (target.ProjectTarget != null)
            {
                ProfileProjectTarget(session, target.ProjectTarget, openReport);
            }
            else if (target.StandaloneTarget != null)
            {
                ProfileStandaloneTarget(session, target.StandaloneTarget, openReport);
            }
            else
            {
                if (MessageBox.Show("Profiling session is not configured - would you like to configure now and then launch?", "No Profiling Target", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    var newTarget = session.OpenTargetProperties();
                    if (newTarget != null && (newTarget.ProjectTarget != null || newTarget.StandaloneTarget != null))
                    {
                        StartProfiling(newTarget, session, openReport);
                    }
                }
            }
        }
        internal void StartProfiling(ProfilingTarget target, SessionNode session, bool openReport = true)
        {
            if (!Utilities.SaveDirtyFiles())
            {
                // Abort
                return;
            }

            if (target.ProjectTarget != null)
            {
                ProfileProjectTarget(session, target.ProjectTarget, openReport);
            }
            else if (target.StandaloneTarget != null)
            {
                ProfileStandaloneTarget(session, target.StandaloneTarget, openReport);
            }
            else
            {
                if (MessageBox.Show(Resources.NoProfilingConfiguredMessageText, Resources.NoProfilingConfiguredMessageCaption, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    var newTarget = session.OpenTargetProperties();
                    if (newTarget != null && (newTarget.ProjectTarget != null || newTarget.StandaloneTarget != null))
                    {
                        StartProfiling(newTarget, session, openReport);
                    }
                }
            }
        }
        private void StartPerfAnalysis(object sender, EventArgs e)
        {
            var view = new ProfilingTargetView();

            var         sessions      = ShowPerformanceExplorer().Sessions;
            SessionNode activeSession = sessions.ActiveSession;

            if (activeSession == null ||
                activeSession.Target.ProjectTarget == null ||
                !ProjectTarget.IsSame(activeSession.Target.ProjectTarget, view.Project.GetTarget()))
            {
                // need to create a new session
                var target = new ProfilingTarget()
                {
                    ProjectTarget = view.Project.GetTarget()
                };

                activeSession = AddPerformanceSession(
                    view.Project.Name,
                    target
                    );
            }

            ProfileProjectTarget(activeSession, activeSession.Target.ProjectTarget, true);
        }
示例#4
0
        internal SessionNode OpenTarget(ProfilingTarget target, string filename)
        {
            for (int i = 0; i < _sessions.Count; i++)
            {
                if (_sessions[i].Filename == filename)
                {
                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Performance '{0}' session is already open", filename));
                }
            }

            uint prevSibl;

            if (_sessions.Count > 0)
            {
                prevSibl = _sessions[_sessions.Count - 1].ItemId;
            }
            else
            {
                prevSibl = VSConstants.VSITEMID_NIL;
            }

            var node = new SessionNode(this, target, filename);

            _sessions.Add(node);

            OnItemAdded(VSConstants.VSITEMID_ROOT, prevSibl, node.ItemId);

            if (_activeSession == VSConstants.VSITEMID_NIL)
            {
                SetActiveSession(node);
            }

            return(node);
        }
示例#5
0
        public SessionNode(SessionsNode parent, ProfilingTarget target, string filename)
        {
            _parent   = parent;
            _target   = target;
            _filename = filename;

            // Register this with the running document table.  This will prompt for save when the file is dirty and
            // by responding to GetProperty for VSHPROPID_ItemDocCookie we will support Ctrl-S when one of our
            // files is dirty.
            // http://msdn.microsoft.com/en-us/library/bb164600(VS.80).aspx
            IVsRunningDocumentTable rdt = NodejsProfilingPackage.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
            uint   cookie;
            IntPtr punkDocData = Marshal.GetIUnknownForObject(this);

            try
            {
                ErrorHandler.ThrowOnFailure(rdt.RegisterAndLockDocument((uint)(_VSRDTFLAGS.RDT_VirtualDocument | _VSRDTFLAGS.RDT_EditLock | _VSRDTFLAGS.RDT_CanBuildFromMemory), filename, this, VSConstants.VSITEMID_ROOT, punkDocData, out cookie));
            }
            finally
            {
                if (punkDocData != IntPtr.Zero)
                {
                    Marshal.Release(punkDocData);
                }
            }
            _docCookie = cookie;

            ItemId = parent._sessionsCollection.Add(this);
        }
        private void AddPerformanceSession(object sender, EventArgs e)
        {
            string baseName = "Performance";
            var    target   = new ProfilingTarget();

            AddPerformanceSession(baseName, target);
        }
        INodeProfileSession INodeProfiling.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 NodejsProfilingPackage.Instance.ProfileTarget(target, openReport).GetAutomationObject();
        }
        internal SessionNode ProfileTarget(ProfilingTarget target, bool openReport = true)
        {
            bool   save;
            string name    = target.GetProfilingName(out save);
            var    session = ShowPerformanceExplorer().Sessions.AddTarget(target, name, save);

            StartProfiling(target, session, openReport);
            return(session);
        }
示例#9
0
        internal SessionNode AddTarget(ProfilingTarget target, string filename, bool save)
        {
            Debug.Assert(filename.EndsWith(NodejsProfilingPackage.PerfFileType, StringComparison.Ordinal));

            // 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 + NodejsProfilingPackage.PerfFileType;
            // 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);
        }
示例#10
0
        INodeProfileSession INodeProfiling.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(NodejsProfilingPackage.Instance.ProfileTarget(target, openReport).GetAutomationObject());
        }
示例#11
0
 /// <summary>
 /// Create a ProfilingTargetView with values taken from a template.
 /// </summary>
 /// <param name="template"></param>
 public ProfilingTargetView(ProfilingTarget template)
     : this() {
     if (template.ProjectTarget != null) {
         Project = new ProjectTargetView(template.ProjectTarget);
         IsStandaloneSelected = false;
         IsProjectSelected = true;
     } else if (template.StandaloneTarget != null) {
         Standalone = new StandaloneTargetView(template.StandaloneTarget);
         IsProjectSelected = false;
         IsStandaloneSelected = true;
     }
     _startText = Resources.ProfilingOk;
 }
示例#12
0
 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);
 }
示例#13
0
        INodeProfileSession INodeProfiling.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 (interpreter.IndexOfAny(Path.GetInvalidPathChars()) == -1 && File.Exists(interpreter)) {
                target.StandaloneTarget.InterpreterPath = interpreter;
            } else {
                throw new InvalidOperationException(String.Format("Invalid interpreter: {0}", interpreter));
            }

            return NodejsProfilingPackage.Instance.ProfileTarget(target, openReport).GetAutomationObject();
        }
示例#14
0
        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();
            }

            return res;
        }
示例#15
0
 /// <summary>
 /// Create a ProfilingTargetView with values taken from a template.
 /// </summary>
 /// <param name="template"></param>
 public ProfilingTargetView(ProfilingTarget template)
     : this()
 {
     if (template.ProjectTarget != null)
     {
         Project = new ProjectTargetView(template.ProjectTarget);
         IsStandaloneSelected = false;
         IsProjectSelected    = true;
     }
     else if (template.StandaloneTarget != null)
     {
         Standalone           = new StandaloneTargetView(template.StandaloneTarget);
         IsProjectSelected    = false;
         IsStandaloneSelected = true;
     }
     _startText = Resources.ProfilingOk;
 }
示例#16
0
        internal SessionNode AddTarget(ProfilingTarget target, string filename, bool save) {
            Debug.Assert(filename.EndsWith(NodejsProfilingPackage.PerfFileType));

            // 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 + NodejsProfilingPackage.PerfFileType;
            // 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;
        }
示例#17
0
        internal ProfilingTarget OpenTargetProperties()
        {
            var targetView = new ProfilingTargetView(_target);
            var dialog     = new LaunchProfiling(targetView);
            var res        = dialog.ShowModal() ?? false;

            if (res && targetView.IsValid)
            {
                var target = targetView.GetTarget();
                if (target != null && !ProfilingTarget.IsSame(target, _target))
                {
                    _target = target;
                    MarkDirty();
                    return(_target);
                }
            }
            return(null);
        }
示例#18
0
        INodeProfileSession INodeProfiling.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 (interpreter.IndexOfAny(Path.GetInvalidPathChars()) == -1 && File.Exists(interpreter))
            {
                target.StandaloneTarget.InterpreterPath = interpreter;
            }
            else
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Invalid interpreter: {0}", interpreter));
            }

            return(NodejsProfilingPackage.Instance.ProfileTarget(target, openReport).GetAutomationObject());
        }
        private SessionNode AddPerformanceSession(string baseName, ProfilingTarget target)
        {
            var dte = (EnvDTE.DTE)NodejsProfilingPackage.GetGlobalService(typeof(EnvDTE.DTE));

            string filename;
            int?   id   = null;
            bool   save = false;

            do
            {
                filename = baseName + id + PerfFileType;
                if (dte.Solution.IsOpen && !String.IsNullOrEmpty(dte.Solution.FullName))
                {
                    filename = Path.Combine(Path.GetDirectoryName(dte.Solution.FullName), filename);
                    save     = true;
                }
                id = (id ?? 0) + 1;
            } while (File.Exists(filename));
            return(ShowPerformanceExplorer().Sessions.AddTarget(target, filename, save));
        }
示例#20
0
        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();
            }

            return(res);
        }
        public SessionNode(SessionsNode parent, ProfilingTarget target, string filename) {
            _parent = parent;
            _target = target;
            _filename = filename;

            // Register this with the running document table.  This will prompt for save when the file is dirty and
            // by responding to GetProperty for VSHPROPID_ItemDocCookie we will support Ctrl-S when one of our
            // files is dirty.
            // http://msdn.microsoft.com/en-us/library/bb164600(VS.80).aspx
            IVsRunningDocumentTable rdt = NodejsProfilingPackage.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
            uint cookie;
            IntPtr punkDocData = Marshal.GetIUnknownForObject(this);
            try {
                ErrorHandler.ThrowOnFailure(rdt.RegisterAndLockDocument((uint)(_VSRDTFLAGS.RDT_VirtualDocument | _VSRDTFLAGS.RDT_EditLock | _VSRDTFLAGS.RDT_CanBuildFromMemory), filename, this, VSConstants.VSITEMID_ROOT, punkDocData, out cookie));
            } finally {
                if (punkDocData != IntPtr.Zero) {
                    Marshal.Release(punkDocData);
                }
            }
            _docCookie = cookie;

            ItemId = parent._sessionsCollection.Add(this);
        }
        internal void StartProfiling(ProfilingTarget target, SessionNode session, bool openReport = true) {
            if (!Utilities.SaveDirtyFiles()) {
                // Abort
                return;
            }

            if (target.ProjectTarget != null) {
                ProfileProjectTarget(session, target.ProjectTarget, openReport);
            } else if (target.StandaloneTarget != null) {
                ProfileStandaloneTarget(session, target.StandaloneTarget, openReport);
            } else {
                if (MessageBox.Show("Profiling session is not configured - would you like to configure now and then launch?", "No Profiling Target", MessageBoxButton.YesNo) == MessageBoxResult.Yes) {
                    var newTarget = session.OpenTargetProperties();
                    if (newTarget != null && (newTarget.ProjectTarget != null || newTarget.StandaloneTarget != null)) {
                        StartProfiling(newTarget, session, openReport);
                    }
                }
            }
        }
示例#23
0
        internal SessionNode OpenTarget(ProfilingTarget target, string filename) {
            for (int i = 0; i < _sessions.Count; i++) {
                if (_sessions[i].Filename == filename) {
                    throw new InvalidOperationException(String.Format("Performance '{0}' session is already open", filename));
                }
            }

            uint prevSibl;
            if (_sessions.Count > 0) {
                prevSibl = _sessions[_sessions.Count - 1].ItemId;
            } else {
                prevSibl = VSConstants.VSITEMID_NIL;
            }

            var node = new SessionNode(this, target, filename);
            _sessions.Add(node);

            OnItemAdded(VSConstants.VSITEMID_ROOT, prevSibl, node.ItemId);

            if (_activeSession == VSConstants.VSITEMID_NIL) {
                SetActiveSession(node);
            }

            return node;
        }
示例#24
0
 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;
 }
 internal ProfilingTarget OpenTargetProperties() {
     var targetView = new ProfilingTargetView(_target);
     var dialog = new LaunchProfiling(targetView);
     var res = dialog.ShowModal() ?? false;
     if (res && targetView.IsValid) {
         var target = targetView.GetTarget();
         if (target != null && !ProfilingTarget.IsSame(target, _target)) {
             _target = target;
             MarkDirty();
             return _target;
         }
     }
     return null;
 }
        private SessionNode AddPerformanceSession(string baseName, ProfilingTarget target) {
            var dte = (EnvDTE.DTE)NodejsProfilingPackage.GetGlobalService(typeof(EnvDTE.DTE));

            string filename;
            int? id = null;
            bool save = false;
            do {
                filename = baseName + id + PerfFileType;
                if (dte.Solution.IsOpen && !String.IsNullOrEmpty(dte.Solution.FullName)) {
                    filename = Path.Combine(Path.GetDirectoryName(dte.Solution.FullName), filename);
                    save = true;
                }
                id = (id ?? 0) + 1;
            } while (File.Exists(filename));
            return ShowPerformanceExplorer().Sessions.AddTarget(target, filename, save);
        }
 private void AddPerformanceSession(object sender, EventArgs e) {
     string baseName = "Performance";
     var target = new ProfilingTarget();
     AddPerformanceSession(baseName, target);
 }
        internal void StartProfiling(ProfilingTarget target, SessionNode session, bool openReport = true) {
            if (!Utilities.SaveDirtyFiles()) {
                // Abort
                return;
            }

            if (target.ProjectTarget != null) {
                ProfileProjectTarget(session, target.ProjectTarget, openReport);
            } else if (target.StandaloneTarget != null) {
                ProfileStandaloneTarget(session, target.StandaloneTarget, openReport);
            } else {
                if (MessageBox.Show(Resources.NoProfilingConfiguredMessageText, Resources.NoProfilingConfiguredMessageCaption, MessageBoxButton.YesNo) == MessageBoxResult.Yes) {
                    var newTarget = session.OpenTargetProperties();
                    if (newTarget != null && (newTarget.ProjectTarget != null || newTarget.StandaloneTarget != null)) {
                        StartProfiling(newTarget, session, openReport);
                    }
                }
            }
        }
        internal SessionNode ProfileTarget(ProfilingTarget target, bool openReport = true) {
            bool save;
            string name = target.GetProfilingName(out save);
            var session = ShowPerformanceExplorer().Sessions.AddTarget(target, name, save);

            StartProfiling(target, session, openReport);
            return session;
        }
        private void StartPerfAnalysis(object sender, EventArgs e) {
            var view = new ProfilingTargetView();
            
            var sessions = ShowPerformanceExplorer().Sessions;
            SessionNode activeSession = sessions.ActiveSession;
            if (activeSession == null ||
                activeSession.Target.ProjectTarget == null ||
                !ProjectTarget.IsSame(activeSession.Target.ProjectTarget, view.Project.GetTarget())) {
                // need to create a new session
                    var target = new ProfilingTarget() { ProjectTarget = view.Project.GetTarget() };
                    
                    activeSession = AddPerformanceSession(
                        view.Project.Name, 
                        target
                    );
            }

            ProfileProjectTarget(activeSession, activeSession.Target.ProjectTarget, true);
        }