Exemple #1
0
 internal QuicScheduleData(Timestamp timeStamp, TimestampDelta duration, uint threadId, QuicScheduleState state)
 {
     TimeStamp = timeStamp;
     Duration  = duration;
     ThreadId  = threadId;
     State     = state;
 }
 public PerfettoSystemMemoryEvent(double value, string memoryType, Timestamp startTimestamp, TimestampDelta duration)
 {
     this.Value          = value;
     this.MemoryType     = memoryType;
     this.StartTimestamp = startTimestamp;
     this.Duration       = duration;
 }
 public PerfettoFrameEvent(string FrameType,
                           string processName,
                           uint upid,
                           long displayToken,
                           long surfaceToken,
                           TimestampDelta duration,
                           Timestamp startTimestamp,
                           Timestamp endTimestamp,
                           string JankType,
                           string JankTag,
                           string PresentType,
                           string PredictionType,
                           string OnTimeFinish,
                           string GpuComposition)
 {
     this.FrameType         = Common.StringIntern(FrameType);
     this.ProcessName       = Common.StringIntern(processName);
     this.Upid              = upid;
     this.DisplayFrameToken = displayToken;
     this.SurfaceFrameToken = surfaceToken;
     this.Duration          = duration;
     this.StartTimestamp    = startTimestamp;
     this.EndTimestamp      = endTimestamp;
     this.JankType          = Common.StringIntern(JankType);
     this.JankTag           = Common.StringIntern(JankTag);
     this.PresentType       = Common.StringIntern(PresentType);
     this.PredictionType    = Common.StringIntern(PredictionType);
     this.OnTimeFinish      = OnTimeFinish;
     this.GpuComposition    = GpuComposition;
 }
                    public string Format(string format, object arg, IFormatProvider formatProvider)
                    {
                        if (arg == null)
                        {
                            return(string.Empty);
                        }

                        TimestampDelta numerator;

                        if (arg is TimeRange)
                        {
                            numerator = ((TimeRange)arg).Duration;
                        }
                        else if (arg is TimestampDelta)
                        {
                            numerator = (TimestampDelta)arg;
                        }
                        else
                        {
                            throw new FormatException();
                        }

                        TimestampDelta viewportDuration = getViewportDuration();
                        double         percent          = (viewportDuration != TimestampDelta.Zero) ?
                                                          (100.0 * ((double)numerator.ToNanoseconds) / (viewportDuration.ToNanoseconds)) :
                                                          100.0;

                        return(percent.ToString(format, formatProvider));
                    }
        /// <summary>
        /// For populating the current counter values
        /// </summary>
        public PerfettoCpuCountersEvent(int cpuNum, Timestamp startTimestamp, TimestampDelta duration,
                                        double userNs,
                                        double userNiceNs,
                                        double systemModeNs,
                                        double idleNs,
                                        double ioWaitNs,
                                        double irqNs,
                                        double softIrqNs)
        {
            this.CpuNum         = cpuNum;
            this.StartTimestamp = startTimestamp;
            this.Duration       = duration;

            this.UserNs       = userNs;
            this.UserNiceNs   = userNiceNs;
            this.SystemModeNs = systemModeNs;
            this.IdleNs       = idleNs;
            this.IoWaitNs     = ioWaitNs;
            this.IrqNs        = irqNs;
            this.SoftIrqNs    = softIrqNs;

            this.CpuPercent        = 0;
            this.UserPercent       = 0;
            this.UserNicePercent   = 0;
            this.SystemModePercent = 0;
            this.IdlePercent       = 0;
            this.IoWaitPercent     = 0;
            this.IrqPercent        = 0;
            this.SoftIrqPercent    = 0;
        }
Exemple #6
0
 /// <summary>
 /// For populating the current counter values
 /// </summary>
 public PerfettoGpuCountersEvent(string name, double value, Timestamp startTimestamp, TimestampDelta duration)
 {
     this.Name           = Common.StringIntern(name);
     this.Value          = value;
     this.StartTimestamp = startTimestamp;
     this.Duration       = duration;
 }
Exemple #7
0
 internal QuicExecutionData(Timestamp timeStamp, uint threadId, ushort procesor, TimestampDelta duration, QuicExecutionType type)
 {
     TimeStamp = timeStamp;
     ThreadId  = threadId;
     Processor = procesor;
     Duration  = duration;
     Type      = type;
 }
Exemple #8
0
 internal Data(QuicConnection connection, bool tx, Timestamp time, TimestampDelta duration, ulong rate)
 {
     Connection = connection;
     Tx         = tx;
     Time       = time;
     Duration   = duration;
     Rate       = rate;
 }
Exemple #9
0
 internal Data(QuicConnection connection, string type, Timestamp time, TimestampDelta duration, ulong bytes)
 {
     Connection = connection;
     Type       = type;
     Time       = time;
     Duration   = duration;
     Bytes      = bytes;
 }
 internal Data(QuicDatapath datapath, bool tx, Timestamp time, TimestampDelta duration, ulong rate)
 {
     Datapath = datapath;
     Tx       = tx;
     Time     = time;
     Duration = duration;
     Rate     = rate;
 }
Exemple #11
0
 internal QuicApiData(QuicApiType type, ushort procesor, uint processId, uint threadId,
                      Timestamp timeStamp, TimestampDelta duration, ulong pointer, uint result)
 {
     Type      = type;
     Processor = procesor;
     ProcessId = processId;
     ThreadId  = threadId;
     TimeStamp = timeStamp;
     Duration  = duration;
     Pointer   = pointer;
     Result    = result;
 }
Exemple #12
0
        public IReadOnlyList <QuicDatapathData> GetDatapathEvents(long resolutionNanoSec = 25 * 1000 * 1000) // 25 ms default
        {
            var Resolution = new TimestampDelta(resolutionNanoSec);

            int eventCount = Events.Count;
            int eventIndex = 0;

            var sample         = new QuicDatapathData();
            var datapathEvents = new List <QuicDatapathData>();

            foreach (var evt in Events)
            {
                if (eventIndex == 0)
                {
                    sample.TimeStamp = evt.TimeStamp;
                }
                eventIndex++;

                if (evt.EventId == QuicEventId.DatapathSend)
                {
                    var _evt = evt as QuicDatapathSendEvent;
                    sample.BytesSent += _evt !.TotalSize;
                    sample.SendEventCount++;
                }
                else if (evt.EventId == QuicEventId.DatapathRecv)
                {
                    var _evt = evt as QuicDatapathRecvEvent;
                    sample.BytesReceived += _evt !.TotalSize;
                    sample.ReceiveEventCount++;
                }
                else
                {
                    continue;
                }

                if (sample.TimeStamp + Resolution <= evt.TimeStamp || eventIndex == eventCount)
                {
                    sample.Duration = evt.TimeStamp - sample.TimeStamp;
                    sample.TxRate   = (sample.BytesSent * 8 * 1000 * 1000 * 1000) / (ulong)sample.Duration.ToNanoseconds;
                    sample.RxRate   = (sample.BytesReceived * 8 * 1000 * 1000 * 1000) / (ulong)sample.Duration.ToNanoseconds;

                    datapathEvents.Add(sample);

                    sample.TimeStamp         = evt.TimeStamp;
                    sample.BytesSent         = 0;
                    sample.BytesReceived     = 0;
                    sample.SendEventCount    = 0;
                    sample.ReceiveEventCount = 0;
                }
            }
            return(datapathEvents);
        }
 public DurationLogEntry(LogEntry logEntry, Timestamp startTimestamp, TimestampDelta duration, string name) : base(LogParsedDataKey.GeneralLog)
 {
     StartTimestamp = startTimestamp;
     EndTimestamp   = logEntry.Timestamp;
     Duration       = duration;
     FilePath       = logEntry.FilePath;
     LineNumber     = logEntry.LineNumber;
     PID            = logEntry.PID;
     TID            = logEntry.TID;
     Priority       = logEntry.Priority;
     Tag            = logEntry.Tag;
     Message        = logEntry.Message;
     Name           = name;
 }
 public void SwitchOut(LTTngEvent data, ThreadState newState)
 {
     this.ExecTimeNs           += data.Timestamp - this.lastEventTimestamp;
     this.currentState          = ThreadStateToSchedulingState(newState);
     this.previousState         = SchedulingState.Running;
     this.lastEventTimestamp    = data.Timestamp;
     this.previousSwitchOutTime = data.Timestamp;
     this.readyingPid           = String.Empty;
     this.readyingTid           = String.Empty;
     if (this.isTerminated())
     {
         this.ExitTime = data.Timestamp;
     }
 }
Exemple #15
0
 public Thread(ThreadInfo threadInfo)
 {
     this.tid           = threadInfo.Tid;
     this.pidAsInt      = threadInfo.Pid;
     this.pidAsString   = threadInfo.PidAsString();
     this.command       = threadInfo.Command;
     this.startTime     = threadInfo.StartTime;
     this.exitTime      = threadInfo.ExitTime;
     this.execTime      = threadInfo.ExecTimeNs;
     this.readyTime     = threadInfo.ReadyTimeNs;
     this.sleepTime     = threadInfo.SleepTimeNs;
     this.diskSleepTime = threadInfo.DiskSleepTimeNs;
     this.stoppedTime   = threadInfo.StoppedTimeNs;
     this.parkedTime    = threadInfo.ParkedTimeNs;
     this.idleTime      = threadInfo.IdleTimeNs;
 }
        /// <summary>
        /// When we have a previous event to compare to, we can calculate the percent change
        /// </summary>
        public PerfettoCpuCountersEvent(int cpuNum, Timestamp startTimestamp, TimestampDelta duration,
                                        double userNs,
                                        double userNiceNs,
                                        double systemModeNs,
                                        double idleNs,
                                        double ioWaitNs,
                                        double irqNs,
                                        double softIrqNs,
                                        PerfettoCpuCountersEvent previousEvent)
        {
            this.CpuNum         = cpuNum;
            this.StartTimestamp = startTimestamp;
            this.Duration       = duration;

            this.UserNs       = userNs;
            this.UserNiceNs   = userNiceNs;
            this.SystemModeNs = systemModeNs;
            this.IdleNs       = idleNs;
            this.IoWaitNs     = ioWaitNs;
            this.IrqNs        = irqNs;
            this.SoftIrqNs    = softIrqNs;

            var timeDiff = (this.StartTimestamp.ToNanoseconds - previousEvent.StartTimestamp.ToNanoseconds);

            if (timeDiff != 0)
            {
                this.UserPercent       = (this.UserNs - previousEvent.UserNs) / timeDiff * 100;
                this.UserNicePercent   = (this.UserNiceNs - previousEvent.UserNiceNs) / timeDiff * 100;
                this.SystemModePercent = (this.SystemModeNs - previousEvent.SystemModeNs) / timeDiff * 100;
                this.IdlePercent       = (this.IdleNs - previousEvent.IdleNs) / timeDiff * 100;
                this.IoWaitPercent     = (this.IoWaitNs - previousEvent.IoWaitNs) / timeDiff * 100;
                this.IrqPercent        = (this.IrqNs - previousEvent.IrqNs) / timeDiff * 100;
                this.SoftIrqPercent    = (this.SoftIrqNs - previousEvent.SoftIrqNs) / timeDiff * 100;
                this.CpuPercent        = 100 - IdlePercent;
            }
            else
            {
                this.CpuPercent        = 0;
                this.UserPercent       = 0;
                this.UserNicePercent   = 0;
                this.SystemModePercent = 0;
                this.IdlePercent       = 0;
                this.IoWaitPercent     = 0;
                this.IrqPercent        = 0;
                this.SoftIrqPercent    = 0;
            }
        }
 public ExecutionEvent(ContextSwitch contextSwitch, Timestamp switchOutTime)
 {
     this.cpu             = contextSwitch.Cpu;
     this.nextPid         = contextSwitch.NextPid;
     this.nextTid         = contextSwitch.NextTid;
     this.previousPid     = contextSwitch.PreviousPid;
     this.previousTid     = contextSwitch.PreviousTid;
     this.priority        = contextSwitch.Priority;
     this.readyingPid     = contextSwitch.ReadyingPid;
     this.readyingTid     = contextSwitch.ReadyingTid;
     this.previousState   = contextSwitch.PreviousState;
     this.nextCommand     = contextSwitch.NextImage;
     this.previousCommand = contextSwitch.PreviousImage;
     this.readyTime       = contextSwitch.ReadyTime;
     this.waitTime        = contextSwitch.WaitTime;
     this.switchInTime    = contextSwitch.SwitchInTime;
     this.switchOutTime   = switchOutTime;
     this.nextThreadPreviousSwitchOutTime = contextSwitch.NextThreadPreviousSwitchOutTime;
 }
 public PerfettoCpuSchedEvent(string processName,
                              string threadName,
                              long tid,
                              TimestampDelta duration,
                              Timestamp startTimestamp,
                              Timestamp endTimestamp,
                              uint cpu,
                              string endState,
                              int priority)
 {
     this.ProcessName    = Common.StringIntern(processName);
     this.ThreadName     = Common.StringIntern(threadName);
     this.Tid            = tid;
     this.Duration       = duration;
     this.StartTimestamp = startTimestamp;
     this.EndTimestamp   = endTimestamp;
     this.Cpu            = cpu;
     this.EndState       = endState;
     this.Priority       = priority;
 }
        private void stateTransition(Timestamp newEventTimestamp, ThreadState newState)
        {
            TimestampDelta nanosecondsToAdd = newEventTimestamp - this.lastEventTimestamp;

            this.lastEventTimestamp = newEventTimestamp;
            var prevState = this.currentState;

            this.currentState = ThreadStateToSchedulingState(newState);
            switch (prevState)
            {
            case SchedulingState.Running:
            case SchedulingState.NewlyCreated:
                ///Adding to ready time because exec time is added after a context switch
                this.ReadyTimeNs += nanosecondsToAdd;
                return;

            case SchedulingState.Sleeping:
                this.SleepTimeNs += nanosecondsToAdd;
                break;

            case SchedulingState.DiskSleeping:
                this.DiskSleepTimeNs += nanosecondsToAdd;
                break;

            case SchedulingState.Stopped:
                this.StoppedTimeNs += nanosecondsToAdd;
                break;

            case SchedulingState.Parked:
                this.ParkedTimeNs += nanosecondsToAdd;
                break;

            case SchedulingState.Idle:
                this.IdleTimeNs += nanosecondsToAdd;
                break;
            }
            ///Only set if current state is not running
            this.previousState    = prevState;
            this.previousWaitTime = nanosecondsToAdd;
        }
 public ContextSwitch(LTTngEvent data, ThreadInfo nextThread, ThreadInfo previousThread, uint cpu)
 {
     this.cpu         = cpu;
     this.nextPid     = nextThread.PidAsString();
     this.nextTid     = nextThread.Tid;
     this.previousPid = previousThread.PidAsString();
     this.previousTid = previousThread.Tid;
     this.priority    = data.Payload.ReadFieldAsInt32("_next_prio");
     if (nextThread.currentState == ThreadInfo.SchedulingState.Running)
     {
         this.readyingPid   = nextThread.readyingPid;
         this.readyingTid   = nextThread.readyingTid;
         this.readyTime     = data.Timestamp - nextThread.lastEventTimestamp;
         this.previousState = ThreadInfo.SchedulingStateToString(nextThread.previousState);
         if (nextThread.previousState == ThreadInfo.SchedulingState.Running ||
             nextThread.previousState == ThreadInfo.SchedulingState.NewlyCreated ||
             nextThread.previousState == ThreadInfo.SchedulingState.Unknown)
         {
             this.waitTime = new TimestampDelta(0);
         }
         else
         {
             this.waitTime = nextThread.previousWaitTime;
         }
     }
     else
     {
         this.readyingPid   = string.Empty;
         this.readyingTid   = string.Empty;
         this.readyTime     = new TimestampDelta(0);
         this.waitTime      = data.Timestamp - nextThread.lastEventTimestamp;
         this.previousState = ThreadInfo.SchedulingStateToString(nextThread.currentState);
     }
     this.nextCommand     = data.Payload.ReadFieldAsArray("_next_comm").GetValueAsString();
     this.previousCommand = data.Payload.ReadFieldAsArray("_prev_comm").GetValueAsString();
     this.switchInTime    = data.Timestamp;
     this.nextThreadPreviousSwitchOutTime = nextThread.previousSwitchOutTime;
 }
 public PerfettoGenericEvent(
     int sliceId,
     string eventName,
     string type,
     TimestampDelta duration,
     TimestampDelta durationExclusive,
     Timestamp startTimestamp,
     Timestamp endTimestamp,
     string category,
     Dictionary <string, object> args,
     string process,
     string processLabel,
     string thread,
     string provider,
     PerfettoThreadTrackEvent threadTrack,
     int?parentId,
     int parentTreeDepthLevel,
     string[] parentEventNameTree)
 {
     SliceId              = sliceId;
     EventName            = Common.StringIntern(eventName);
     Type                 = Common.StringIntern(type);
     Duration             = duration;
     DurationExclusive    = durationExclusive;
     StartTimestamp       = startTimestamp;
     EndTimestamp         = endTimestamp;
     Category             = Common.StringIntern(category);
     Args                 = args;
     Process              = Common.StringIntern(process);
     ProcessLabel         = Common.StringIntern(processLabel);
     Thread               = Common.StringIntern(thread);
     Provider             = Common.StringIntern(provider);
     ThreadTrack          = threadTrack;
     ParentId             = parentId;
     ParentTreeDepthLevel = parentTreeDepthLevel;
     ParentEventNameTree  = parentEventNameTree;
 }
        private static double ProjectPercentWeight(ValueTuple <QuicWorker, QuicActivityData> data)
        {
            TimestampDelta TimeNs = data.Item1.FinalTimeStamp - data.Item1.InitialTimeStamp;

            return(100.0 * data.Item2.Duration.ToNanoseconds / TimeNs.ToNanoseconds);
        }
Exemple #23
0
 internal QuicActivityData(Timestamp timeStamp, TimestampDelta duration)
 {
     TimeStamp = timeStamp;
     Duration  = duration;
 }
        public PerfettoProcessMemoryEvent(string processName, Timestamp startTimestamp, TimestampDelta duration,
                                          double rssAnon,
                                          double rssShMem,
                                          double rssFile,
                                          double rssHwm,
                                          double rss,
                                          double locked,
                                          double swap,
                                          double virt)
        {
            this.ProcessName    = processName;
            this.StartTimestamp = startTimestamp;
            this.Duration       = duration;

            this.RssAnon  = rssAnon;
            this.Locked   = locked;
            this.RssShMem = rssShMem;
            this.RssFile  = rssFile;
            this.RssHwm   = rssHwm;
            this.Rss      = rss;
            this.Swap     = swap;
            this.Virt     = virt;
        }
        private static double ProjectPercentWeight(Data data)
        {
            TimestampDelta TimeNs = data.Connection.FinalTimeStamp - data.Connection.InitialTimeStamp;

            return(100.0 * data.BlockedData.Duration.ToNanoseconds / TimeNs.ToNanoseconds);
        }
Exemple #26
0
        public void OnDataAvailable(IDataExtensionRetrieval requiredData)
        {
            // Gather the data from all the SQL tables
            var counterData         = requiredData.QueryOutput <ProcessedEventData <PerfettoCounterEvent> >(new DataOutputPath(PerfettoPluginConstants.CounterCookerPath, nameof(PerfettoCounterCooker.CounterEvents)));
            var cpuCounterTrackData = requiredData.QueryOutput <ProcessedEventData <PerfettoCpuCounterTrackEvent> >(new DataOutputPath(PerfettoPluginConstants.CpuCounterTrackCookerPath, nameof(PerfettoCpuCounterTrackCooker.CpuCounterTrackEvents)));

            // Join them all together
            // Counter table contains the timestamp and all /proc/stat counters
            // CpuCounterTrack contains the counter name and CPU core
            var joined = from counter in counterData
                         join cpuCounterTrack in cpuCounterTrackData on counter.TrackId equals cpuCounterTrack.Id
                         where cpuCounterTrack.Name.StartsWith("cpu.times")
                         orderby counter.Timestamp ascending
                         select new { counter, cpuCounterTrack };

            // 7 different CPU counters are polled at regular intervals through the trace, for each CPU core.
            // The names and cores are stored in the cpu_counter_track table and the actual counter values are stored
            // in the counter table
            //
            // We will create one PerfettoCpuCountersEvent for each time grouping that contains all 7 counter values

            foreach (var cpuGroup in joined.GroupBy(x => x.cpuCounterTrack.Cpu))
            {
                var timeGroups = cpuGroup.GroupBy(z => z.counter.RelativeTimestamp);
                PerfettoCpuCountersEvent?lastEvent = null;
                for (int i = 0; i < timeGroups.Count(); i++)
                {
                    var timeGroup = timeGroups.ElementAt(i);

                    long nextTs = timeGroup.Key;
                    if (i < timeGroups.Count() - 1)
                    {
                        // Need to look ahead in the future at the next event to get the timestamp so that we can calculate the duration
                        nextTs = timeGroups.ElementAt(i + 1).Key;
                    }

                    var    cpu            = cpuGroup.Key;
                    var    startTimestamp = new Timestamp(timeGroup.Key);
                    var    duration       = new TimestampDelta(nextTs - timeGroup.Key);
                    double userNs         = 0.0;
                    double userNiceNs     = 0.0;
                    double systemModeNs   = 0.0;
                    double idleNs         = 0.0;
                    double ioWaitNs       = 0.0;
                    double irqNs          = 0.0;
                    double softIrqNs      = 0.0;

                    foreach (var nameGroup in timeGroup.GroupBy(y => y.cpuCounterTrack.Name))
                    {
                        switch (nameGroup.Key)
                        {
                        case "cpu.times.user_ns":
                            userNs = nameGroup.ElementAt(0).counter.FloatValue;
                            break;

                        case "cpu.times.user_nice_ns":
                            userNiceNs = nameGroup.ElementAt(0).counter.FloatValue;
                            break;

                        case "cpu.times.system_mode_ns":
                            systemModeNs = nameGroup.ElementAt(0).counter.FloatValue;
                            break;

                        case "cpu.times.idle_ns":
                            idleNs = nameGroup.ElementAt(0).counter.FloatValue;
                            break;

                        case "cpu.times.io_wait_ns":
                            ioWaitNs = nameGroup.ElementAt(0).counter.FloatValue;
                            break;

                        case "cpu.times.irq_ns":
                            irqNs = nameGroup.ElementAt(0).counter.FloatValue;
                            break;

                        case "cpu.times.softirq_ns":
                            softIrqNs = nameGroup.ElementAt(0).counter.FloatValue;
                            break;
                        }
                    }

                    if (lastEvent == null)
                    {
                        // Can't determine % change from the first event because we don't have the previous event to compare to.
                        // Don't graph this event
                        lastEvent = new PerfettoCpuCountersEvent
                                    (
                            cpu, startTimestamp, duration, userNs, userNiceNs, systemModeNs, idleNs, ioWaitNs, irqNs, softIrqNs
                                    );
                    }
                    else
                    {
                        var ev = new PerfettoCpuCountersEvent
                                 (
                            cpu, startTimestamp, duration, userNs, userNiceNs, systemModeNs, idleNs, ioWaitNs, irqNs, softIrqNs, lastEvent.Value
                                 );
                        lastEvent = ev;
                        this.CpuCountersEvents.AddEvent(ev);
                    }
                }
            }

            this.CpuCountersEvents.FinalizeData();
        }
Exemple #27
0
 public PerfettoCpuFrequencyEvent(double cpuFrequency, int cpuNum, Timestamp startTimestamp, TimestampDelta duration, string name, bool isIdle)
 {
     this.CpuFrequency   = cpuFrequency;
     this.CpuNum         = cpuNum;
     this.StartTimestamp = startTimestamp;
     this.Duration       = duration;
     this.Name           = name;
     this.IsIdle         = isIdle;
 }
        public override void Build(ITableBuilder tableBuilder)
        {
            if (PerfDataTxtLogParsed == null || PerfDataTxtLogParsed.Count == 0)
            {
                return;
            }

            var firstPerfDataTxtLogParsed = PerfDataTxtLogParsed.First().Value;  // First Log

            // Init
            IpStackFrames        = new ConcurrentDictionary <long, StackFrame>();
            SampleThreadDict     = new ConcurrentDictionary <long, int>();
            SampleProcessDict    = new ConcurrentDictionary <long, string>();
            SampleStackWalkEvent = new ConcurrentDictionary <long, ManualResetEvent>();

            var baseProjection = Projection.CreateUsingFuncAdaptor(new Func <int, LinuxPerfScriptStackSourceSample>(i => firstPerfDataTxtLogParsed.GetLinuxPerfScriptSampleByIndex((StackSourceSampleIndex)i)));

            // Calculate sample weights
            var sampleWeights = CalculateSampleWeights(firstPerfDataTxtLogParsed);

            var oneNs      = new TimestampDelta(1);
            var weightProj = baseProjection.Compose(s => s.SampleIndex == StackSourceSampleIndex.Invalid ? TimestampDelta.Zero : new TimestampDelta(Convert.ToInt64(sampleWeights[(int)s.SampleIndex] * 1000000)));

            // Constant columns
            var sampleIndex            = baseProjection.Compose(s => (long)s.SampleIndex);
            var timeStampProjection    = baseProjection.Compose(s => s.SampleIndex == StackSourceSampleIndex.Invalid ? Timestamp.Zero : new Timestamp(Convert.ToInt64(s.TimeRelativeMSec * 1000000)));
            var cpuProjection          = baseProjection.Compose(s => s.SampleIndex == StackSourceSampleIndex.Invalid ? -1 : s.CpuNumber);
            var countProjection        = baseProjection.Compose(s => 1);
            var ipStackFrameProjection = baseProjection.Compose(s => GetIpStackFrame(s, firstPerfDataTxtLogParsed)?.Frame);
            var ipModuleProjection     = baseProjection.Compose(s => GetIpStackFrame(s, firstPerfDataTxtLogParsed)?.Module);
            var threadIdProjection     = baseProjection.Compose(s => GetThreadId(s, firstPerfDataTxtLogParsed));
            var processProjection      = baseProjection.Compose(s => GetProcess(s, firstPerfDataTxtLogParsed));


            // For calculating cpu %
            var timeStampStartProjection = baseProjection.Compose(s => s.SampleIndex == StackSourceSampleIndex.Invalid ? Timestamp.Zero : new Timestamp(Convert.ToInt64(s.TimeRelativeMSec * 1000000)) - new TimestampDelta(Convert.ToInt64(sampleWeights[(int)s.SampleIndex] * 1000000)));
            IProjection <int, Timestamp> viewportClippedStartTimeProj = Projection.ClipTimeToVisibleDomain.Create(timeStampStartProjection);
            IProjection <int, Timestamp> viewportClippedEndTimeProj   = Projection.ClipTimeToVisibleDomain.Create(timeStampProjection);

            IProjection <int, TimestampDelta> clippedWeightProj = Projection.Select(
                viewportClippedEndTimeProj,
                viewportClippedStartTimeProj,
                new ReduceTimeSinceLastDiff());

            IProjection <int, double> weightPercentProj = Projection.VisibleDomainRelativePercent.Create(clippedWeightProj);

            IProjection <int, int> countProj = SequentialGenerator.Create(
                firstPerfDataTxtLogParsed.SampleIndexLimit,
                Projection.Constant(1),
                Projection.Constant(0));

            //
            // Table Configurations describe how your table should be presented to the user:
            // the columns to show, what order to show them, which columns to aggregate, and which columns to graph.
            // You may provide a number of columns in your table, but only want to show a subset of them by default so as not to overwhelm the user.
            // The user can still open the table properties to turn on or off columns.
            // The table configuration class also exposes four (4) columns UI explicitly recognizes: Pivot Column, Graph Column, Left Freeze Column, Right Freeze Column
            // For more information about what these columns do, go to "Advanced Topics" -> "Table Configuration" in our Wiki. Link can be found in README.md
            //

            const string filterIdleSamplesQuery = "[IP]:=\"native_safe_halt\"";

            var utilByCpuStackConfig = new TableConfiguration("Utilization by CPU, Stack")
            {
                Columns = new[]
                {
                    cpuColumn,
                    callStackColumn,
                    TableConfiguration.PivotColumn,
                    processColumn,
                    threadIdColumn,
                    instructionPointerColumn,
                    instructionPointerModuleColumn,
                    sampleNumberColumn,
                    timestampDateTimeColumn,
                    timestampColumn,
                    weightColumn,
                    countColumn,
                    TableConfiguration.GraphColumn,
                    weightPctColumn
                },
                InitialFilterShouldKeep = false,
                InitialFilterQuery      = filterIdleSamplesQuery,
            };

            utilByCpuStackConfig.AddColumnRole(ColumnRole.EndTime, timestampColumn);
            utilByCpuStackConfig.AddColumnRole(ColumnRole.Duration, weightColumn);
            utilByCpuStackConfig.AddColumnRole(ColumnRole.ResourceId, cpuColumn);

            var utilByCpuConfig = new TableConfiguration("Utilization by CPU")
            {
                Columns = new[]
                {
                    cpuColumn,
                    TableConfiguration.PivotColumn,
                    countColumn,
                    callStackColumn,
                    processColumn,
                    threadIdColumn,
                    instructionPointerColumn,
                    instructionPointerModuleColumn,
                    sampleNumberColumn,
                    timestampDateTimeColumn,
                    timestampColumn,
                    weightColumn,
                    TableConfiguration.GraphColumn,
                    weightPctColumn
                },
                InitialFilterShouldKeep = false,
                InitialFilterQuery      = filterIdleSamplesQuery,
            };

            utilByCpuConfig.AddColumnRole(ColumnRole.EndTime, timestampColumn);
            utilByCpuConfig.AddColumnRole(ColumnRole.Duration, weightColumn);
            utilByCpuConfig.AddColumnRole(ColumnRole.ResourceId, cpuColumn);

            var utilByProcessConfig = new TableConfiguration("Utilization by Process")
            {
                Columns = new[]
                {
                    processColumn,
                    TableConfiguration.PivotColumn,
                    countColumn,
                    callStackColumn,
                    cpuColumn,
                    threadIdColumn,
                    instructionPointerColumn,
                    instructionPointerModuleColumn,
                    sampleNumberColumn,
                    timestampDateTimeColumn,
                    timestampColumn,
                    weightColumn,
                    TableConfiguration.GraphColumn,
                    weightPctColumn
                },
                InitialFilterShouldKeep = false,
                InitialFilterQuery      = filterIdleSamplesQuery,
            };

            utilByProcessConfig.AddColumnRole(ColumnRole.EndTime, timestampColumn);
            utilByProcessConfig.AddColumnRole(ColumnRole.Duration, weightColumn);
            utilByProcessConfig.AddColumnRole(ColumnRole.ResourceId, cpuColumn);

            var utilByProcessStackConfig = new TableConfiguration("Utilization by Process, Stack")
            {
                Columns = new[]
                {
                    processColumn,
                    callStackColumn,
                    TableConfiguration.PivotColumn,
                    countColumn,
                    cpuColumn,
                    threadIdColumn,
                    instructionPointerColumn,
                    instructionPointerModuleColumn,
                    sampleNumberColumn,
                    timestampDateTimeColumn,
                    timestampColumn,
                    weightColumn,
                    TableConfiguration.GraphColumn,
                    weightPctColumn
                },
                InitialFilterShouldKeep = false,
                InitialFilterQuery      = filterIdleSamplesQuery,
            };

            utilByProcessStackConfig.AddColumnRole(ColumnRole.EndTime, timestampColumn);
            utilByProcessStackConfig.AddColumnRole(ColumnRole.Duration, weightColumn);
            utilByProcessStackConfig.AddColumnRole(ColumnRole.ResourceId, cpuColumn);

            var flameByProcessStackConfig = new TableConfiguration("Flame by Process, Stack")
            {
                Columns = new[]
                {
                    processColumn,
                    callStackColumn,
                    TableConfiguration.PivotColumn,
                    countColumn,
                    cpuColumn,
                    threadIdColumn,
                    instructionPointerColumn,
                    instructionPointerModuleColumn,
                    sampleNumberColumn,
                    timestampDateTimeColumn,
                    timestampColumn,
                    weightColumn,
                    TableConfiguration.GraphColumn,
                    weightPctColumn
                },
                ChartType = ChartType.Flame,
                InitialFilterShouldKeep = false,
                InitialFilterQuery      = filterIdleSamplesQuery,
            };

            flameByProcessStackConfig.AddColumnRole(ColumnRole.EndTime, timestampColumn);
            flameByProcessStackConfig.AddColumnRole(ColumnRole.Duration, weightColumn);
            flameByProcessStackConfig.AddColumnRole(ColumnRole.ResourceId, cpuColumn);

            //
            //
            //  Use the table builder to build the table.
            //  Add and set table configuration if applicable.
            //  Then set the row count (we have one row per file) and then add the columns using AddColumn.
            //
            var table = tableBuilder
                        .AddTableConfiguration(utilByCpuStackConfig)
                        .SetDefaultTableConfiguration(utilByCpuStackConfig)
                        .AddTableConfiguration(utilByCpuConfig)
                        .AddTableConfiguration(utilByProcessConfig)
                        .AddTableConfiguration(utilByProcessStackConfig)
                        .AddTableConfiguration(flameByProcessStackConfig)
                        .SetRowCount(firstPerfDataTxtLogParsed.SampleIndexLimit)
                        .AddColumn(sampleNumberColumn, sampleIndex)
                        .AddColumn(timestampColumn, timeStampProjection)
                        .AddColumn(instructionPointerColumn, ipStackFrameProjection)
                        .AddColumn(instructionPointerModuleColumn, ipModuleProjection)
                        .AddColumn(countColumn, countProjection)
                        .AddColumn(weightColumn, weightProj)
                        .AddColumn(threadIdColumn, threadIdProjection)
                        .AddColumn(processColumn, processProjection)
                        .AddColumn(weightPctColumn, weightPercentProj)
                        .AddColumn(startTimeCol, timeStampStartProjection)
                        .AddColumn(viewportClippedStartTimeCol, viewportClippedStartTimeProj)
                        .AddColumn(viewportClippedEndTimeCol, viewportClippedEndTimeProj)
                        .AddColumn(clippedWeightCol, clippedWeightProj)
                        .AddColumn(cpuColumn, cpuProjection)
            ;

            table.AddHierarchicalColumn(callStackColumn, baseProjection.Compose((i) => GetCallStack(i, firstPerfDataTxtLogParsed)), new ArrayAccessProvider <string>());
        }
Exemple #29
0
 internal QuicActivityData(Timestamp timeStamp, TimestampDelta duration, ushort processor)
 {
     TimeStamp = timeStamp;
     Duration  = duration;
     Processor = processor;
 }
Exemple #30
0
 internal QuicFlowBlockedData(Timestamp timeStamp, TimestampDelta duration, QuicFlowBlockedFlags flags)
 {
     TimeStamp = timeStamp;
     Duration  = duration;
     Flags     = flags;
 }