private static void RunProfiler(SessionNode session, string interpreter, string script, string arguments, string workingDir, bool openReport, ProcessorArchitecture arch) { var process = new ProfiledProcess(interpreter, String.Format("\"{0}\" {1}", script, arguments), workingDir, arch); string baseName = Path.GetFileNameWithoutExtension(session.Filename); string date = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString(); string outPath = Path.Combine(Path.GetTempPath(), baseName + date + ".vsp"); int count = 1; while (File.Exists(outPath)) { outPath = Path.Combine(Path.GetTempPath(), baseName + date + "(" + count + ").vsp"); count++; } process.ProcessExited += (sender, args) => { var dte = (EnvDTE.DTE)PythonProfilingPackage.GetGlobalService(typeof(EnvDTE.DTE)); _profilingProcess = null; _stopCommand.Enabled = false; _startCommand.Enabled = true; if (openReport) { dte.ItemOperations.OpenFile(outPath); } }; session.AddProfile(outPath); process.StartProfiling(outPath); _profilingProcess = process; _stopCommand.Enabled = true; _startCommand.Enabled = false; }
private static void RunProfiler(SessionNode session, LaunchConfiguration config, bool openReport) { var process = new ProfiledProcess( (PythonToolsService)session._serviceProvider.GetService(typeof(PythonToolsService)), config.GetInterpreterPath(), string.Join(" ", ProcessOutput.QuoteSingleArgument(config.ScriptName), config.ScriptArguments), config.WorkingDirectory, session._serviceProvider.GetPythonToolsService().GetFullEnvironment(config) ); string baseName = Path.GetFileNameWithoutExtension(session.Filename); string date = DateTime.Now.ToString("yyyyMMdd"); string outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + ".vsp"); int count = 1; while (File.Exists(outPath)) { outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + "(" + count + ").vsp"); count++; } process.ProcessExited += (sender, args) => { var dte = (EnvDTE.DTE)session._serviceProvider.GetService(typeof(EnvDTE.DTE)); _profilingProcess = null; _stopCommand.Enabled = false; _startCommand.Enabled = true; if (openReport && File.Exists(outPath)) { for (int retries = 10; retries > 0; --retries) { try { using (new FileStream(outPath, FileMode.Open, FileAccess.Read, FileShare.None)) { } break; } catch (IOException) { Thread.Sleep(100); } } dte.ItemOperations.OpenFile(outPath); } }; session.AddProfile(outPath); process.StartProfiling(outPath); _profilingProcess = process; _stopCommand.Enabled = true; _startCommand.Enabled = false; }
private static void RunProfiler(SessionNode session, string interpreter, string script, string arguments, string workingDir, Dictionary <string, string> env, bool openReport, ProcessorArchitecture arch) { var process = new ProfiledProcess( (PythonToolsService)session._serviceProvider.GetService(typeof(PythonToolsService)), interpreter, String.Format("\"{0}\" {1}", script, arguments ?? string.Empty), workingDir, env, arch ); string baseName = Path.GetFileNameWithoutExtension(session.Filename); string date = DateTime.Now.ToString("yyyyMMdd"); string outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + ".vsp"); int count = 1; while (File.Exists(outPath)) { outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + "(" + count + ").vsp"); count++; } process.ProcessExited += (sender, args) => { var dte = (EnvDTE.DTE)session._serviceProvider.GetService(typeof(EnvDTE.DTE)); _profilingProcess = null; _stopCommand.Enabled = false; _startCommand.Enabled = true; if (openReport && File.Exists(outPath)) { dte.ItemOperations.OpenFile(outPath); } }; session.AddProfile(outPath); process.StartProfiling(outPath); _profilingProcess = process; _stopCommand.Enabled = true; _startCommand.Enabled = false; }
private static void RunProfiler(SessionNode session, LaunchConfiguration config, bool openReport) { var process = new ProfiledProcess( (PythonToolsService)session._serviceProvider.GetService(typeof(PythonToolsService)), config.GetInterpreterPath(), string.Join(" ", ProcessOutput.QuoteSingleArgument(config.ScriptName), config.ScriptArguments), config.WorkingDirectory, session._serviceProvider.GetPythonToolsService().GetFullEnvironment(config) ); string baseName = Path.GetFileNameWithoutExtension(session.Filename); string date = DateTime.Now.ToString("yyyyMMdd"); string outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + ".vsp"); int count = 1; while (File.Exists(outPath)) { outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + "(" + count + ").vsp"); count++; } process.ProcessExited += (sender, args) => { var dte = (EnvDTE.DTE)session._serviceProvider.GetService(typeof(EnvDTE.DTE)); _profilingProcess = null; _stopCommand.Enabled = false; _startCommand.Enabled = true; if (openReport && File.Exists(outPath)) { dte.ItemOperations.OpenFile(outPath); } }; session.AddProfile(outPath); process.StartProfiling(outPath); _profilingProcess = process; _stopCommand.Enabled = true; _startCommand.Enabled = false; }
private static void RunProfiler(SessionNode session, string interpreter, string script, string arguments, string workingDir, Dictionary<string, string> env, bool openReport, ProcessorArchitecture arch) { var process = new ProfiledProcess( (PythonToolsService)session._serviceProvider.GetService(typeof(PythonToolsService)), interpreter, String.Format("\"{0}\" {1}", script, arguments ?? string.Empty), workingDir, env, arch ); string baseName = Path.GetFileNameWithoutExtension(session.Filename); string date = DateTime.Now.ToString("yyyyMMdd"); string outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + ".vsp"); int count = 1; while (File.Exists(outPath)) { outPath = Path.Combine(Path.GetTempPath(), baseName + "_" + date + "(" + count + ").vsp"); count++; } process.ProcessExited += (sender, args) => { var dte = (EnvDTE.DTE)session._serviceProvider.GetService(typeof(EnvDTE.DTE)); _profilingProcess = null; _stopCommand.Enabled = false; _startCommand.Enabled = true; if (openReport && File.Exists(outPath)) { dte.ItemOperations.OpenFile(outPath); } }; session.AddProfile(outPath); process.StartProfiling(outPath); _profilingProcess = process; _stopCommand.Enabled = true; _startCommand.Enabled = false; }