Ejemplo n.º 1
0
 public static void Enable(TraceConfiguration traceConfig)
 {
     m_enableMethod.Invoke(
         null,
         new object[]
     {
         traceConfig.ConfigurationObject
     });
 }
Ejemplo n.º 2
0
        static int Main(string[] args)
        {
            TimeSpan profSampleDelay = TimeSpan.FromMilliseconds(1);
            string   outputFile      = "default.netperf";

            Assembly SPC           = typeof(System.Diagnostics.Tracing.EventSource).Assembly;
            Type     eventPipeType = SPC.GetType("System.Diagnostics.Tracing.EventPipe");

            m_enableMethod  = eventPipeType.GetMethod("Enable", BindingFlags.NonPublic | BindingFlags.Static);
            m_disableMethod = eventPipeType.GetMethod("Disable", BindingFlags.NonPublic | BindingFlags.Static);

            // Setup the configuration values.
            uint circularBufferMB = 1024; // 1 GB
            uint level            = 5;    // Verbose

            // Create a new instance of EventPipeConfiguration.
            TraceConfiguration config = new TraceConfiguration(outputFile, circularBufferMB);
            // Setup the provider values.
            // Public provider.
            string providerName = "Microsoft-Windows-DotNETRuntime";
            UInt64 keywords     = 0x4c14fccbd;

            // Enable the provider.
            config.EnableProvider(providerName, keywords, level);

            // Private provider.
            providerName = "Microsoft-Windows-DotNETRuntimePrivate";
            keywords     = 0x4002000b;

            // Enable the provider.
            config.EnableProvider(providerName, keywords, level);

            // Sample profiler.
            providerName = "Microsoft-DotNETCore-SampleProfiler";
            keywords     = 0x0;

            // Enable the provider.
            config.EnableProvider(providerName, keywords, level);

            // Set the sampling rate.
            config.SetSamplingRate(profSampleDelay);

            // Enable tracing.
            Enable(config);
            Disable();
            Enable(config);

            return(100);
        }