Exemplo n.º 1
0
        private void EmitEvent(ProfilingMessageType profilingType, string textFormat, params object[] textFormatArguments)
        {
            // Perform a Mark event only if the profiling is running
            if (!isEnabled)
            {
                return;
            }

            var timeStamp = Stopwatch.GetTimestamp();

            // In the case of begin/end, reuse the text from the `begin`event
            // if the text is null for `end` event.
            var text = textFormat != null?string.Format(textFormat, textFormatArguments) : profilingType == ProfilingMessageType.Mark ? null : beginText;

            if (profilingType == ProfilingMessageType.Begin)
            {
                startTime = timeStamp;
                beginText = text;
            }
            else if (profilingType == ProfilingMessageType.End)
            {
                beginText = null;
            }

            // Create profiler event
            // TODO ideally we should make a copy of the attributes
            var profilerEvent = new ProfilingEvent(ProfilingId, ProfilingKey, profilingType, timeStamp, timeStamp - startTime, text, attributes);

            // Send profiler event to Profiler
            Profiler.ProcessEvent(ref profilerEvent, eventType);
        }
Exemplo n.º 2
0
        private void EmitEvent(ProfilingMessageType profilingType, string text, ProfilingCustomValue?value0, ProfilingCustomValue?value1, ProfilingCustomValue?value2, ProfilingCustomValue?value3)
        {
            // Perform a Mark event only if the profiling is running
            if (!isEnabled)
            {
                return;
            }

            var timeStamp = Stopwatch.GetTimestamp();

            if (profilingType == ProfilingMessageType.Begin)
            {
                startTime = timeStamp;
            }

            //this actually stores the LAST text into beginText so to be able to add it at the end
            if (profilingType != ProfilingMessageType.End && text != null)
            {
                beginText = text;
            }

            // Create profiler event
            var profilerEvent = new ProfilingEvent(ProfilingId, ProfilingKey, profilingType, timeStamp, timeStamp - startTime, beginText ?? text, attributes, value0, value1, value2, value3);

            if (profilingType == ProfilingMessageType.End)
            {
                beginText = null;
            }

            // Send profiler event to Profiler
            Profiler.ProcessEvent(ref profilerEvent, eventType);
        }
Exemplo n.º 3
0
        private void EmitEvent(ProfilingMessageType profilingType, string text, long timeStamp)
        {
            // Perform a Mark event only if the profiling is running
            if (!isEnabled)
            {
                return;
            }

            // In the case of begin/end, reuse the text from the `begin`event
            // if the text is null for `end` event.
            if (text == null && profilingType != ProfilingMessageType.Mark)
            {
                text = beginText;
            }

            if (profilingType == ProfilingMessageType.Begin)
            {
                startTime = timeStamp;
                beginText = text;
            }
            else if (profilingType == ProfilingMessageType.End)
            {
                beginText = null;
                isEnabled = false;
            }

            // Create profiler event
            // TODO ideally we should make a copy of the attributes
            var profilerEvent = new ProfilingEvent(ProfilingId, ProfilingKey, profilingType, timeStamp, timeStamp - startTime, text, attributes);

            // Send profiler event to Profiler
            Profiler.ProcessEvent(ref profilerEvent, eventType);
        }
Exemplo n.º 4
0
        public static void ProcessEvent(ref ProfilingEvent profilingEvent, ProfilingEventType eventType)
        {
            // Add event
            lock (Locker)
            {
                var list = eventType == ProfilingEventType.CpuProfilingEvent ? cpuEvents.GetBuffer() : gpuEvents.GetBuffer();
                list.Add(profilingEvent);
            }

            // Log it
            if ((profilingEvent.Key.Flags & ProfilingKeyFlags.Log) != 0)
            {
                Logger.Log(new ProfilingMessage(profilingEvent.Id, profilingEvent.Key, profilingEvent.Type)
                {
                    Attributes = profilingEvent.Attributes, ElapsedTime = new TimeSpan((profilingEvent.ElapsedTime * 10000000) / Stopwatch.Frequency), Text = profilingEvent.Text
                });
            }
        }