public ExperimentProcess(string channelName, string suiteAssemblyLocation, string suiteTypeName, Type testerType, Type testedType, string testName, PerfTestConfiguration configuration) { this.experimentProcess = new Process { StartInfo = new ProcessStartInfo { UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = false, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, FileName = Environment.CurrentDirectory + "\\NPerf.Experiment.exe" }, }; this.ChannelName = channelName; this.suiteAssemblyLocation = suiteAssemblyLocation; this.suiteTypeName = suiteTypeName; this.testerType = testerType; this.testedType = testedType; this.testName = testName; this.perfTestConfiguration = configuration; this.experimentProcess.ErrorDataReceived += this.experimentProcess_ErrorDataReceived; }
public ExecutionContext(PerfTestConfiguration configuration) { this.lab = new PerfLab(typeof(StringBuildingTester).Assembly, typeof(StringRunner).Assembly, typeof(Dictionary<,>).Assembly); this.RunTests(); //this.RunSomeTests(); this.perfTestConfiguration = configuration; }
internal static IObservable <PerfTestResult> Run(TestInfo[] testInfo, PerfTestConfiguration configuration, bool parallel = false) { return(testInfo.Select(x => x.Suite) .Distinct() .ToObservable() .SelectMany(suite => CreateRunObservable(suite, x => testInfo.FirstOrDefault( test => test.TestId.Equals(x.TestId)) != null, processes => processes.Start(!parallel), configuration, parallel))); }
internal static IObservable<PerfTestResult> Run(TestInfo[] testInfo, PerfTestConfiguration configuration, bool parallel = false) { return testInfo.Select(x => x.Suite) .Distinct() .ToObservable() .SelectMany(suite => CreateRunObservable(suite, x => testInfo.FirstOrDefault( test => test.TestId.Equals(x.TestId)) != null, processes => processes.Start(!parallel), configuration, parallel)); }
public void Copy(PerfTestConfiguration configuration) { this.IgnoreFirstRunDueToJITting = configuration.IgnoreFirstRunDueToJITting; this.TriggerGCBeforeEachTest = configuration.TriggerGCBeforeEachTest; }
public void SetPerfTestConfiguration(PerfTestConfiguration configuration) { PerfTestConfigurationTemp = configuration; PerfTestConfiguration = configuration.Clone(); _propertyGrid.SelectedObject = PerfTestConfiguration; }
public static IObservable <PerfTestResult> Run(TestSuiteInfo testSuiteInfo, int start, int step, int end, PerfTestConfiguration configuration, bool parallel = false) { return(CreateRunObservable(testSuiteInfo, x => true, processes => processes.Start(start, step, end, !parallel), configuration, parallel)); }
private static IObservable <PerfTestResult> CreateRunObservable(TestSuiteInfo testSuiteInfo, Predicate <TestInfo> testFilter, Action <ExperimentProcess> startProcess, PerfTestConfiguration configuration, bool parallel = false) { return(Observable.Create <PerfTestResult>( observer => { var assemblyLocation = BuildTestSuiteAssembly(testSuiteInfo); var processes = new MultiExperimentProcess( (from testMethod in testSuiteInfo.Tests where testFilter(testMethod) select new ExperimentProcess( string.Format( "{0}.{1}({2})", testSuiteInfo.TesterType.Name, testMethod.TestMethodName, testMethod.TestedType.Name), assemblyLocation, TestSuiteCodeBuilder.TestSuiteClassName, testSuiteInfo.TesterType, testMethod.TestedType, testMethod.TestMethodName, configuration)).ToArray()); var listeners = Observable.Empty <PerfTestResult>(); if (!parallel) { listeners = processes.Experiments.Aggregate(listeners, (current, experiment) => current.Concat( new SingleExperimentListener(experiment, startProcess))); } else { listeners = from experiment in processes.Experiments.ToObservable() from result in new SingleExperimentListener(experiment, startProcess) select result; } IDisposable subscription = null; subscription = listeners.SubscribeSafe(observer); return Disposable.Create( () => { if (subscription != null) { subscription.Dispose(); subscription = null; } processes.Dispose(); if (!string.IsNullOrEmpty(assemblyLocation)) { File.Delete(assemblyLocation); } }); })); }
private void PrepareStart() { this.perfTestConfiguration = new PerfTestConfiguration(Settings.Default.IgnoreFirstRunDueToJITting, Settings.Default.TriggerGCBeforeEachTest); IsStarted = true; foreach (var series in memorySeries.Select(m => m.Value) .Union(speedSeries.Select(s => s.Value))) { series.Points.Clear(); } SpeedPlotModel.RefreshPlot(true); MemoryPlotModel.RefreshPlot(true); }
public IObservable<PerfTestResult> Run(Guid[] tests, int start, int step, int end, PerfTestConfiguration configuration, bool parallel = false) { return TestSuiteManager.Run(tests.Select(x => this.Tests[x]).ToArray(), start, step, end, configuration, parallel); }
public static IObservable<PerfTestResult> Run(TestSuiteInfo testSuiteInfo, int start, int step, int end, PerfTestConfiguration configuration, bool parallel = false) { return CreateRunObservable(testSuiteInfo, x => true, processes => processes.Start(start, step, end, !parallel), configuration, parallel); }
private static IObservable<PerfTestResult> CreateRunObservable(TestSuiteInfo testSuiteInfo, Predicate<TestInfo> testFilter, Action<ExperimentProcess> startProcess, PerfTestConfiguration configuration, bool parallel = false) { return Observable.Create<PerfTestResult>( observer => { var assemblyLocation = BuildTestSuiteAssembly(testSuiteInfo); var processes = new MultiExperimentProcess( (from testMethod in testSuiteInfo.Tests where testFilter(testMethod) select new ExperimentProcess( string.Format( "{0}.{1}({2})", testSuiteInfo.TesterType.Name, testMethod.TestMethodName, testMethod.TestedType.Name), assemblyLocation, TestSuiteCodeBuilder.TestSuiteClassName, testSuiteInfo.TesterType, testMethod.TestedType, testMethod.TestMethodName, configuration)).ToArray()); var listeners = Observable.Empty<PerfTestResult>(); if (!parallel) { listeners = processes.Experiments.Aggregate(listeners, (current, experiment) => current.Concat( new SingleExperimentListener(experiment, startProcess))); } else { listeners = from experiment in processes.Experiments.ToObservable() from result in new SingleExperimentListener(experiment, startProcess) select result; } IDisposable subscription = null; subscription = listeners.SubscribeSafe(observer); return Disposable.Create( () => { if (subscription != null) { subscription.Dispose(); subscription = null; } processes.Dispose(); if (!string.IsNullOrEmpty(assemblyLocation)) { File.Delete(assemblyLocation); } }); }); }
public ChartViewModel(PerfLab lab, TestSuiteInfo suiteInfo) { this.perfTestConfiguration = new PerfTestConfiguration(Settings.Default.IgnoreFirstRunDueToJITting, Settings.Default.TriggerGCBeforeEachTest); this.Title = suiteInfo.TestSuiteDescription; Lab = lab; TestSuiteInfo = suiteInfo; this.StartValue = 1; this.EndValue = suiteInfo.DefaultTestCount; this.StepValue = 1; SpeedPlotModel = new PlotModel(string.Format("\"{0}\": Time characteristics", suiteInfo.TestSuiteDescription)); SpeedPlotModel.Axes.Clear(); SpeedPlotModel.Axes.Add(new LinearAxis(AxisPosition.Bottom, suiteInfo.FeatureDescription)); MemoryPlotModel = new PlotModel(string.Format("\"{0}\": Memory usage", suiteInfo.TestSuiteDescription)); MemoryPlotModel.Axes.Clear(); MemoryPlotModel.Axes.Add(new LinearAxis(AxisPosition.Bottom, suiteInfo.FeatureDescription)); memorySeries = new Dictionary<TestInfo, LineSeries>(); speedSeries = new Dictionary<TestInfo, LineSeries>(); IsLinear = true; IsStarted = false; var errorHandler = IoC.Instance.Resolve<ErrorHandler>(); var whenStarted = this.WhenAny(x => x.IsStarted, x => x.Value); this.StartSequential = new ReactiveAsyncCommand(whenStarted.Select(x => !x)); StartSequential.RegisterAsyncAction(OnStartSequential, RxApp.DeferredScheduler); errorHandler.HandleErrors(this.StartSequential); this.StartParallel = new ReactiveAsyncCommand(whenStarted.Select(x => !x)); StartParallel.RegisterAsyncAction(OnStartParallel, RxApp.DeferredScheduler); errorHandler.HandleErrors(this.StartParallel); this.Stop = new ReactiveAsyncCommand(whenStarted); Stop.RegisterAsyncAction(OnStop, RxApp.DeferredScheduler); errorHandler.HandleErrors(this.Stop); this.WhenAny(x => x.IsLinear, x => x.Value ? EAxisType.Linear : EAxisType.Logarithmic) .Subscribe(SetAxisType); MessageBus.Current.Listen<PerfTestResult>() .Where(x => tests.FirstOrDefault(t => t.TestId.Equals(x.TestId)) != null) .Subscribe( res => { var nextRes = res as NextResult; var errorRes = res as ExperimentError; if (nextRes != null) { AddPoint(memorySeries, MemoryPlotModel, tests.First(x => x.TestId.Equals(res.TestId)), nextRes.Descriptor, nextRes.MemoryUsage); AddPoint(speedSeries, SpeedPlotModel, tests.First(x => x.TestId.Equals(res.TestId)), nextRes.Descriptor, nextRes.Duration); } if (errorRes != null) { var test = tests.FirstOrDefault(x => x.TestId.Equals(errorRes.TestId)); Task.Factory.StartNew(() => errorHandler.ReportExperimentError(errorRes, test)); } }, errorHandler.ReportException); ConnectIterationAndDescriptors(); }
public IObservable <PerfTestResult> Run(Guid[] tests, int start, int step, int end, PerfTestConfiguration configuration, bool parallel = false) { return(TestSuiteManager.Run(tests.Select(x => this.Tests[x]).ToArray(), start, step, end, configuration, parallel)); }
public IObservable<PerfTestResult> Run(int start, int step, int end, PerfTestConfiguration configuration, bool parallel = false) { return this.testSuites.ToObservable().SelectMany(suite => TestSuiteManager.Run(suite, start, step, end, configuration, parallel)); }
public IObservable <PerfTestResult> Run(int start, int step, int end, PerfTestConfiguration configuration, bool parallel = false) { return(this.testSuites.ToObservable().SelectMany(suite => TestSuiteManager.Run(suite, start, step, end, configuration, parallel))); }