示例#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
        static void Main(string[] args)
        {
            string dwjsonDir = "";

            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);
                }

                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 output directory requested and it does not exist, create it

                if (!opts.DryRunRequested)
                {
                    if (opts.DWJsonOutDir == null)
                    {
                        Console.WriteLine($"Need an output directory unless in dry run.");
                        Environment.Exit(1);
                    }
                    else
                    {
                        if (!Directory.Exists(opts.DWJsonOutDir))
                        {
                            try {
                                Directory.CreateDirectory(opts.DWJsonOutDir);
                            } catch (Exception ex) {
                                Console.WriteLine($"Couldn't create specified directory [{opts.DWJsonOutDir}]: {ex.Message}");
                                Environment.Exit(1);
                            }
                        }
                        dwjsonDir = opts.DWJsonOutDir;
                    }
                }

                if (!opts.DryRunRequested)
                {
                    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);
                }
                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);
                }

                /*
                 * Console.WriteLine($"Please check for generated file: [{repspec.ReportOutputFile}]");
                 * Console.WriteLine($"\tand also [{reptimespec.ReportOutputFile}]");
                 * Console.WriteLine($"(Which I should process and dump at directory [{dwjsonDir}]");
                 */

                double runtime = VTuneToDWJSON.CSReportToDWJson(repspec.ReportOutputFile, Path.Combine(dwjsonDir, "Sample.dwjson"));
                VTuneToDWJSON.CPUReportToDWJson(reptimespec.ReportOutputFile, Path.Combine(dwjsonDir, "Session.counters"), runtime);

                Console.WriteLine($"Which I dumped at directory [{dwjsonDir}]");

#if false
                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);
        }