Ejemplo n.º 1
0
        /// <summary>
        /// This constructor is used when the consumer is supplying the buffers for reasons like buffer pooling.
        /// </summary>
        public BPerfEventSource(string btlFilePath, TraceEventDispatcherOptions options, byte[] workspace, byte[] uncompressedBuffer, byte[] compressedBuffer)
        {
            var startTime = options.StartTime == default(DateTime) ? DateTime.MinValue : options.StartTime;
            var endTime   = options.EndTime == default(DateTime) ? DateTime.MaxValue : options.EndTime;

            this.btlFilePath     = btlFilePath;
            this.startFileOffset = 0;
            this.startQPC        = 0;
            this.endFileOffset   = long.MaxValue;
            this.endQPC          = long.MaxValue;

            string indexFile       = this.btlFilePath + ".id";
            bool   indexFileExists = File.Exists(indexFile);

            if (startTime > DateTime.MinValue && indexFileExists)
            {
                this.startFileOffset = GetOffset(indexFile, startTime, out this.startQPC, out var _);
            }

            if (endTime < DateTime.MaxValue && indexFileExists)
            {
                this.endFileOffset = GetOffset(indexFile, endTime, out this.endQPC, out var _);
            }

            this.workspace          = workspace;
            this.uncompressedBuffer = uncompressedBuffer;
            this.compressedBuffer   = compressedBuffer;

            this.ProcessInner();
        }
Ejemplo n.º 2
0
        public void Basic(string bperfFileName)
        {
            // Initialize
            PrepareTestData();

            Output.WriteLine(string.Format("Processing the file {0}, Making ETLX and scanning.", Path.GetFullPath(bperfFileName)));
            var sb = new StringBuilder(1024 * 1024);
            var traceEventDispatcherOptions = new TraceEventDispatcherOptions();

            using (var traceLog = new TraceLog(TraceLog.CreateFromEventTraceLogFile(Path.GetFullPath(bperfFileName), traceEventDispatcherOptions: traceEventDispatcherOptions)))
            {
                var traceSource = traceLog.Events.GetSource();

                traceSource.AllEvents += delegate(TraceEvent data)
                {
                    sb.AppendLine(Parse(data));
                };

                // Process
                traceSource.Process();
            }

            // Validate
            ValidateEventStatistics(sb.ToString(0, 1024 * 1024), Path.GetFileNameWithoutExtension(bperfFileName));
        }
Ejemplo n.º 3
0
        public void Basic(string bperfFileName)
        {
            // Initialize
            PrepareTestData();

            Output.WriteLine(string.Format("Processing the file {0}, Making ETLX and scanning.", Path.GetFullPath(bperfFileName)));
            var sb = new StringBuilder(1024 * 1024);
            var traceEventDispatcherOptions = new TraceEventDispatcherOptions();

            Guid systemTrace = new Guid("9e814aad-3204-11d2-9a82-006008a86939");

            using (var traceLog = new TraceLog(TraceLog.CreateFromEventTraceLogFile(Path.GetFullPath(bperfFileName), traceEventDispatcherOptions: traceEventDispatcherOptions)))
            {
                var traceSource = traceLog.Events.GetSource();

                traceSource.AllEvents += delegate(TraceEvent data)
                {
                    if (data.ProviderGuid != systemTrace || (int)data.Opcode != 80)
                    {
                        sb.AppendLine(Parse(data));
                    }
                };

                // Process
                traceSource.Process();
            }

            // Validate
            ValidateEventStatistics(sb.ToString(0, 1024 * 1024), Path.GetFileNameWithoutExtension(bperfFileName));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This constructor is used when the consumer is supplying the buffers for reasons like buffer pooling.
        /// </summary>
        public BPerfEventSource(string btlFilePath, TraceEventDispatcherOptions options, byte[] uncompressedBuffer, byte[] compressedBuffer, bool skipReadingUnreachableEvents = false, BPerfEventSourceDecompress decompressDelegate = null)
        {
            var startTime = DateTime.MinValue;
            var endTime   = DateTime.MaxValue;

            if (options != null)
            {
                startTime = options.StartTime == default(DateTime) ? DateTime.MinValue : options.StartTime;
                endTime   = options.EndTime == default(DateTime) ? DateTime.MaxValue : options.EndTime;
            }

            this.btlFilePath     = btlFilePath;
            this.startFileOffset = 0;
            this.endQPCForManagedSymbolsInclusion = long.MaxValue;
            this.skipQPC            = 0;
            this.endFileOffset      = long.MaxValue;
            this.canResolveSymbols  = !skipReadingUnreachableEvents;
            this.DecompressDelegate = decompressDelegate;
            if (this.DecompressDelegate == null)
            {
                this.DecompressDelegate = BPerfEventSource.ULZ777Decompress;
            }

            string indexFile       = this.btlFilePath + ".id";
            bool   indexFileExists = File.Exists(indexFile);

            if (indexFileExists)
            {
                var tmp = GetOffset(indexFile, startTime, out this.endQPCForManagedSymbolsInclusion, out var skipqpc);
                if (startTime > DateTime.MinValue)
                {
                    this.skipQPC = skipqpc;

                    if (skipReadingUnreachableEvents)
                    {
                        this.startFileOffset = tmp;
                    }
                }
            }

            if (endTime < DateTime.MaxValue && indexFileExists)
            {
                this.endFileOffset = GetOffset(indexFile, endTime, out _, out _);
            }

            this.uncompressedBuffer = uncompressedBuffer;
            this.compressedBuffer   = compressedBuffer;

            this.ProcessInner();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// This constructor is used when the consumer has an offset within the BTL file that it would like to seek to.
 /// </summary>
 public BPerfEventSource(string btlFilePath, TraceEventDispatcherOptions traceEventDispatcherOptions)
     : this(btlFilePath, traceEventDispatcherOptions, new byte[BufferSize], new byte[BufferSize])
 {
 }