示例#1
0
 public string UserDataDirCLI()
 {
     if (UserDataDir == string.Empty || UserDataDir == null)
     {
         UserDataDir = VTuneInvoker.FreshDirectory();
     }
     return("-user-data-dir=" + UserDataDir); // should be outputdir in PTVS
 }
示例#2
0
文件: Program.cs 项目: yepeiwen/PTVS
        static void Main(string[] args)
        {
            string dwjsonDir = "";

            var parser = new Parser(config => {
                config.EnableDashDash = true;
            });

            var res = parser.ParseArguments <ProgramOptions>(args)
                      .WithParsed <ProgramOptions>(opts => {
                string vtuneExec = "";
                try {
                    vtuneExec = VTuneInvoker.VTunePath();
                } catch (VTuneNotInstalledException ex) {
                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, Strings.VTuneNotFoundInExpectedPath, ex.Message));
                    Environment.Exit(1);
                }

                if (opts.ReportVTunePath)
                {
                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, Strings.VTuneFoundInPath, vtuneExec));
                    Environment.Exit(0);
                }

                var RestArgs = opts.Rest.ToList();
                VTuneCollectHotspotsSpec spec = new VTuneCollectHotspotsSpec()
                {
                    WorkloadSpec = String.Join(" ", RestArgs)
                };

                if (opts.SymbolPath != string.Empty)
                {
                    Console.WriteLine(Strings.SymbolPathSpecifiedNotification);
                    spec.SymbolPath = opts.SymbolPath;
                }

                string vtuneCollectArgs = spec.FullCLI();

                VTuneReportCallstacksSpec repspec = new VTuneReportCallstacksSpec();
                string vtuneReportArgs            = repspec.FullCLI();

                VTuneCPUUtilizationSpec reptimespec = new VTuneCPUUtilizationSpec();
                string vtuneReportTimeArgs          = reptimespec.FullCLI();

                // If output directory requested and it does not exist, create it
                if (!opts.DryRunRequested)
                {
                    if (opts.DWJsonOutDir == null)
                    {
                        Console.WriteLine(Strings.OutputDirRequired);
                        Environment.Exit(1);
                    }
                    else
                    {
                        if (!Directory.Exists(opts.DWJsonOutDir))
                        {
                            try {
                                Directory.CreateDirectory(opts.DWJsonOutDir);
                            } catch (Exception ex) {
                                Console.WriteLine(string.Format(CultureInfo.CurrentCulture, Strings.DirCreationFailed, opts.DWJsonOutDir, ex.Message));
                                Environment.Exit(1);
                            }
                        }
                        dwjsonDir = opts.DWJsonOutDir;
                    }
                }

                if (!opts.DryRunRequested)
                {
                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, Strings.CollectCmdLineDump, vtuneExec, vtuneCollectArgs));
                    ProcessAsyncRunner.RunWrapper(vtuneExec, vtuneCollectArgs);

                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, Strings.CallstackReportCmdLineDump, vtuneExec, vtuneReportArgs));
                    ProcessAsyncRunner.RunWrapper(vtuneExec, vtuneReportArgs);

                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, Strings.TimingReportCmdLineDump, vtuneExec, vtuneReportTimeArgs));
                    ProcessAsyncRunner.RunWrapper(vtuneExec, vtuneReportTimeArgs);
                }
                else
                {
                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, Strings.CollectCmdLineDump, vtuneExec, vtuneCollectArgs));
                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, Strings.CallstackReportCmdLineDump, vtuneExec, vtuneReportArgs));
                    Console.WriteLine(string.Format(CultureInfo.CurrentCulture, Strings.TimingReportCmdLineDump, vtuneExec, vtuneReportTimeArgs));

                    Environment.Exit(0);
                }

                double runtime = VTuneToDWJSON.CSReportToDWJson(repspec.ReportOutputFile, Path.Combine(dwjsonDir, "Sample.dwjson"));
                VTuneToDWJSON.CPUReportToDWJson(reptimespec.ReportOutputFile, Path.Combine(dwjsonDir, "Session.counters"), runtime);
            })
                      .WithNotParsed(errors => {
                Console.WriteLine(Strings.IncorrectCommandLine);
                Environment.Exit(1);
            });

            Environment.Exit(0);
        }
示例#3
0
        static void Main(string[] args)
        {
            var parser = new Parser(config => {
                config.EnableDashDash = true;
            });


            var res = parser.ParseArguments <ProgramOptions>(args)
                      .WithParsed <ProgramOptions>(opts => {
                if (opts.CallStackFNameToParse != null)
                {
                    // TODO: test /tmp/results_20180314/r_stacks_0004.csv
#if false
                    ParseStackReport(opts.CallStackFNameToParse);
#endif
                    Environment.Exit(0);
                }
#if false
                string vtuneExec = "";
                try {
                    vtuneExec = VTuneInvoker.VTunePath();
                } catch (VTuneNotInstalledException ex) {
                    Console.WriteLine($"VTune not found in expected path: {ex.Message}");
                    Environment.Exit(1);
                }

                if (opts.ReportVTunePath)
                {
                    Console.WriteLine($"The path of VTune is: {vtuneExec}");
                    Environment.Exit(0);
                }

                var RestArgs = opts.Rest.ToList();
                VTuneCollectHotspotsSpec spec = new VTuneCollectHotspotsSpec()
                {
                    WorkloadSpec = String.Join(" ", RestArgs)
                };
                string vtuneCollectArgs = spec.FullCLI();

                VTuneReportCallstacksSpec repspec = new VTuneReportCallstacksSpec();
                string vtuneReportArgs            = repspec.FullCLI();

                VTuneCPUUtilizationSpec reptimespec = new VTuneCPUUtilizationSpec();
                string vtuneReportTimeArgs          = reptimespec.FullCLI();

                if (!opts.DryRunRequested)
                {
#if false
                    Console.WriteLine($"Collect command line is: [ {vtuneExec} {vtuneCollectArgs} ]");
                    ProcessAsyncRunner.RunWrapper(vtuneExec, vtuneCollectArgs);

                    Console.WriteLine($"Report callstacks line: [ {vtuneExec} {vtuneReportArgs} ]");
                    ProcessAsyncRunner.RunWrapper(vtuneExec, vtuneReportArgs);

                    Console.WriteLine($"Report timing line: [ {vtuneExec} {vtuneReportTimeArgs} ]");
                    ProcessAsyncRunner.RunWrapper(vtuneExec, vtuneReportTimeArgs);
#endif
                }
                else
                {
                    Console.WriteLine($"Collect command line is: [ {vtuneExec} {vtuneCollectArgs} ]");
                    Console.WriteLine("Report command lines");
                    Console.WriteLine($"[ {vtuneExec} {vtuneReportArgs} ]");
                    Console.WriteLine($"[ {vtuneExec} {vtuneReportTimeArgs} ]");

                    Environment.Exit(0);
                }

                var stackReportFName = repspec.ReportOutputFile;
                if (!File.Exists(stackReportFName))
                {
                    Console.WriteLine("Cannot find the VTune report, something went wrong with the profiler process.");
                    Environment.Exit(1);
                }
#endif
            })
                      .WithNotParsed(errors => {
                Console.WriteLine("Incorrect command line.");
                Environment.Exit(1);
            });


            Environment.Exit(0);
        }