private void InterningStackCountTest(string source, int expectedStackCount) { Constants.WaitUntilFileIsReady(source); ParallelLinuxPerfScriptStackSource stackSource = new ParallelLinuxPerfScriptStackSource(source); Assert.Equal(expectedStackCount, stackSource.Interner.CallStackCount); }
private static void Write(string source) { Constants.WaitUntilFileIsReady(source); var stackSource = new ParallelLinuxPerfScriptStackSource(source); XmlStackSourceWriter.WriteStackViewAsZippedXml(stackSource, Constants.GetOutputPath(Path.GetFileNameWithoutExtension(source) + ".perfView.xml.zip")); }
public void ConcurrentBlockedTime() { string path = Constants.GetTestingFilePath(@"C:\Users\t-lufern\Desktop\Luca\dev\helloworld.trace.zip"); var linearStackSource = new LinuxPerfScriptStackSource(path, true); Constants.WaitUntilFileIsReady(path); var parallelStackSource = new ParallelLinuxPerfScriptStackSource(path, true); Assert.Equal(linearStackSource.TotalBlockedTime, parallelStackSource.TotalBlockedTime); }
private void HeaderTest(string source, bool blockedTime, string[] commands, int[] pids, int[] tids, int[] cpus, double[] times, int[] timeProperties, string[] events, string[] eventProperties, EventKind[] eventKinds, ScheduleSwitch[] switches ) { Constants.WaitUntilFileIsReady(source); using (Stream stream = File.Open(source, FileMode.Open)) { LinuxPerfScriptEventParser parser = new LinuxPerfScriptEventParser(); List <LinuxEvent> samples = parser.ParseSkippingPreamble(stream).ToList(); // Need to make sure we have the same amount of samples Assert.Equal(commands.Length, parser.EventCount); int schedCount = 0; for (int i = 0; i < parser.EventCount; i++) { LinuxEvent linuxEvent = samples[i]; Assert.Equal(commands[i], linuxEvent.Command); Assert.Equal(pids[i], linuxEvent.ProcessID); Assert.Equal(tids[i], linuxEvent.ThreadID); Assert.Equal(cpus[i], linuxEvent.CpuNumber); Assert.Equal(times[i], linuxEvent.TimeMSec); Assert.Equal(timeProperties[i], linuxEvent.TimeProperty); Assert.Equal(events[i], linuxEvent.EventName); Assert.Equal(eventProperties[i], linuxEvent.EventProperty); Assert.Equal(eventKinds == null ? EventKind.Cpu : eventKinds[i], linuxEvent.Kind); SchedulerEvent sched = linuxEvent as SchedulerEvent; if (switches != null && sched != null) { ScheduleSwitch actualSwitch = sched.Switch; ScheduleSwitch expectedSwitch = switches[schedCount++]; Assert.Equal(expectedSwitch.NextCommand, actualSwitch.NextCommand); Assert.Equal(expectedSwitch.NextPriority, actualSwitch.NextPriority); Assert.Equal(expectedSwitch.NextThreadID, actualSwitch.NextThreadID); Assert.Equal(expectedSwitch.PreviousCommand, actualSwitch.PreviousCommand); Assert.Equal(expectedSwitch.PreviousPriority, actualSwitch.PreviousPriority); Assert.Equal(expectedSwitch.PreviousState, actualSwitch.PreviousState); Assert.Equal(expectedSwitch.PreviousThreadID, actualSwitch.PreviousThreadID); } } } }
private void TotalBlockedTimeTest(string source, double expectedTotalBlockedPeriod, bool concurrentTest = false) { Constants.WaitUntilFileIsReady(source); if (concurrentTest) { StartLook = 10; } ParallelLinuxPerfScriptStackSource stackSource = new ParallelLinuxPerfScriptStackSource(source, doThreadTime: true); StartLook = null; Assert.Equal(expectedTotalBlockedPeriod, stackSource.TotalBlockedTime); }
private void DoStackTraceTest(string path, bool doBlockedTime, List <List <string> > callerStacks) { Constants.WaitUntilFileIsReady(path); ParallelLinuxPerfScriptStackSource stackSource = new ParallelLinuxPerfScriptStackSource(path, doBlockedTime); for (int i = 0; i < stackSource.SampleIndexLimit; i++) { var sample = stackSource.GetSampleByIndex((StackSourceSampleIndex)i); var stackIndex = sample.StackIndex; for (int j = 0; (int)stackIndex != -1; j++) { var frameIndex = stackSource.GetFrameIndex(stackIndex); Assert.Equal(callerStacks[i][j], stackSource.GetFrameName(frameIndex, false)); stackIndex = stackSource.GetCallerIndex(stackIndex); } Assert.Equal(-1, (int)stackIndex); } }
private FastStream GetTestStream() { Constants.WaitUntilFileIsReady(Constants.GetTestingFilePath("faststream.txt")); return(new FastStream(Constants.GetTestingFilePath("faststream.txt"))); }