Пример #1
0
        public CollectTraceEventsHelper(CommandLineOptions options)
        {
            if (TraceEventSession.IsElevated() != true)
                throw new InvalidOperationException("Collecting perf events requires administrative privileges.");

            if (options.ClrEvents.Events == ClrTraceEventParser.Keywords.None && options.KernelEvents == KernelTraceEventParser.Keywords.None)
                throw new PowerArgs.ArgException("Must specify at least one CLR or kernel event.");

            // verify session name
            var existingSessions = TraceEventSession.GetActiveSessionNames();

            if (options.Mode == ExecutionMode.Start && existingSessions.Contains(options.TestName))
                throw new InvalidOperationException(string.Format("The session name '{0}' is already in use.", options.TestName));
            else if (options.Mode == ExecutionMode.Stop && !existingSessions.Contains(options.TestName))
                throw new InvalidOperationException(string.Format("The session name '{0}' does not exist.", options.TestName));

            m_traceSession = new TraceEventSession(options.TestName, options.DataFile);

            if (options.Mode == ExecutionMode.Start)
            {
                m_traceSession.BufferSizeMB = 512;

                // starting a new session, enable providers
                m_traceSession.EnableKernelProvider(options.KernelEvents);
                m_traceSession.EnableProvider(ClrTraceEventParser.ProviderGuid, TraceEventLevel.Informational, (ulong)options.ClrEvents.Events);

                // keep the session active after the process terminates
                m_traceSession.StopOnDispose = false;
            }
        }
Пример #2
0
        public TraceEventsReportGenerator(CommandLineOptions commandLineOptions)
        {
            if (!File.Exists(commandLineOptions.DataFile))
                throw new FileNotFoundException("Couldn't find the specified data file.", commandLineOptions.DataFile);

            m_testName = commandLineOptions.TestName;
            m_etlFile = commandLineOptions.DataFile;
            m_process = commandLineOptions.ProcessName;
            m_clrEvents = commandLineOptions.ClrEvents.Events;
            m_kernelEvents = commandLineOptions.KernelEvents;
        }