public void transpose_double2x2_burst() { FunctionPointer <transpose_double2x2.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <transpose_double2x2.TestFunction>(transpose_double2x2.BurstTestFunction); var args = new transpose_double2x2.Arguments(); args.Init(); var burstSampleGroup = new SampleGroup("Burst", SampleUnit.Microsecond); Measure.Method(() => { testFunction.Invoke(ref args); }) .SampleGroup(burstSampleGroup) .WarmupCount(1) .MeasurementCount(10) .Run(); args.Dispose(); }
public void Random_NextFloat4_burst() { FunctionPointer <Random_NextFloat4.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <Random_NextFloat4.TestFunction>(Random_NextFloat4.BurstTestFunction); var args = new Random_NextFloat4.Arguments(); args.Init(); var burstSampleGroup = new SampleGroup("Burst", SampleUnit.Microsecond); Measure.Method(() => { testFunction.Invoke(ref args); }) .SampleGroup(burstSampleGroup) .WarmupCount(1) .MeasurementCount(10) .Run(); args.Dispose(); }
public void transpose_double2x2_mono() { transpose_double2x2.TestFunction testFunction = transpose_double2x2.MonoTestFunction; var args = new transpose_double2x2.Arguments(); args.Init(); var monoSampleGroup = new SampleGroup("Mono", SampleUnit.Microsecond); Measure.Method(() => { testFunction.Invoke(ref args); }) .SampleGroup(monoSampleGroup) .WarmupCount(1) .MeasurementCount(10) .Run(); args.Dispose(); }
public void Random_NextDouble3_mono() { Random_NextDouble3.TestFunction testFunction = Random_NextDouble3.MonoTestFunction; var args = new Random_NextDouble3.Arguments(); args.Init(); var monoSampleGroup = new SampleGroup("Mono", SampleUnit.Microsecond); Measure.Method(() => { testFunction.Invoke(ref args); }) .SampleGroup(monoSampleGroup) .WarmupCount(1) .MeasurementCount(10) .Run(); args.Dispose(); }
public void float4x4_fastinverse_mono() { float4x4_fastinverse.TestFunction testFunction = float4x4_fastinverse.MonoTestFunction; var args = new float4x4_fastinverse.Arguments(); args.Init(); var monoSampleGroup = new SampleGroup("Mono", SampleUnit.Microsecond); Measure.Method(() => { testFunction.Invoke(ref args); }) .SampleGroup(monoSampleGroup) .WarmupCount(1) .MeasurementCount(10) .Run(); args.Dispose(); }
public void float4x4_fastinverse_burst() { FunctionPointer <float4x4_fastinverse.TestFunction> testFunction = BurstCompiler.CompileFunctionPointer <float4x4_fastinverse.TestFunction>(float4x4_fastinverse.BurstTestFunction); var args = new float4x4_fastinverse.Arguments(); args.Init(); var burstSampleGroup = new SampleGroup("Burst", SampleUnit.Microsecond); Measure.Method(() => { testFunction.Invoke(ref args); }) .SampleGroup(burstSampleGroup) .WarmupCount(1) .MeasurementCount(10) .Run(); args.Dispose(); }
public void cellular3D_mono() { cellular3D.TestFunction testFunction = cellular3D.MonoTestFunction; var args = new cellular3D.Arguments(); args.Init(); var monoSampleGroup = new SampleGroup("Mono", SampleUnit.Microsecond); Measure.Method(() => { testFunction.Invoke(ref args); }) .SampleGroup(monoSampleGroup) .WarmupCount(1) .MeasurementCount(10) .Run(); args.Dispose(); }
public void SyncDesign_Test_PullCountTree() { var(master, comps) = MakeFiles(numComponents: 2); var compVMs = comps.Select((x, i) => { return(new ComponentFile() { Database = x, Component_CN = i }); }) .ToArray(); var comp1 = comps.First(); var comp1Sg1 = new SampleGroup() { Code = "nsg1", PrimaryProduct = "01", CutLeave = "C", UOM = "01", }; comp1.Insert(comp1Sg1, keyValue: 1000); var compCt1 = new CountTree() { CuttingUnit_CN = 1, SampleGroup_CN = 1000, Tally_CN = 1, }; comp1.Insert(compCt1); MergeSyncWorker.SyncDesign( master, compVMs, new System.Threading.CancellationToken(), (IProgress <int>)null, TestMergeLogWriter); var mastCt1 = master.From <CountTree>() .Join("SampleGroup", "USING (SampleGroup_CN)") .Where("Code = @p1").Query("nsg1").FirstOrDefault(); mastCt1.Should().NotBeNull(); }
public SampleGroup Load(SampleSuite suite) { Type suiteType = suite.GetType(); // get attributes attached to suite DescriptionAttribute descriptionAttribute = (DescriptionAttribute)Attribute.GetCustomAttribute(suiteType, typeof(DescriptionAttribute)); TitleAttribute titleAttribute = (TitleAttribute)Attribute.GetCustomAttribute(suiteType, typeof(TitleAttribute)); PrefixAttribute prefixAttribute = (PrefixAttribute)Attribute.GetCustomAttribute(suiteType, typeof(PrefixAttribute)); if (prefixAttribute == null) { throw new InvalidOperationException("[Prefix] attribute not specified on " + suiteType.Name); } string prefix = prefixAttribute.Prefix; SampleGroup suiteGroup = new SampleGroup(suite, (titleAttribute != null) ? titleAttribute.Title : "", (descriptionAttribute != null) ? descriptionAttribute.Description : ""); string sourceFile = FindSourceFile(suiteType.Name + ".cs"); string sourceCode = (sourceFile != null) ? File.ReadAllText(sourceFile) : ""; MethodInfo[] categoriesObj = suiteType.GetMethods(); List <string> categories = new List <string>(); foreach (MethodInfo c in categoriesObj) { if (c.Name.StartsWith(prefix) == true) { CategoryAttribute[] attributes = (CategoryAttribute[])c.GetCustomAttributes(typeof(CategoryAttribute), false); if (attributes.Length > 0) { if (categories.Contains(attributes[0].Category) == false) { categories.Add(attributes[0].Category); } } } } foreach (string cat in categories) { suiteGroup.Children.Add(LoadCategory(suite, cat, prefix, sourceCode)); } return(suiteGroup); }
public void GetAllSamplesByGivenSearchParams_FilteredByBacteriaNameAndGroup_ShouldReturnRelevantSamples() { // Arrange var db = this.GetDatabase(); var mapper = this.GetAutoMapper(); var searchParams = new SearchParametersBindingModel() { BacteriaName = "New Sample" }; var sample = new Sample() { Name = "New Sample" }; var group = new Group() { Name = "group1" }; var sampleGroup = new SampleGroup() { Sample = sample, Group = group, }; db.Samples.Add(sample); db.Groups.Add(group); db.SampleGroups.Add(sampleGroup); db.SaveChanges(); var service = new SampleService(db, mapper); // Act var result = service.GetAllSamplesByGivenSearchParams(searchParams); // Assert Assert.NotNull(result); Assert.IsType <List <SampleViewModel> >(result); var sampleName = result[0].Name; Assert.Equal("New Sample", sampleName); }
public IEnumerator MeasureFrames_WithSampleGroups_ConvertToPassedSampleUnit() { var sg = new SampleGroup("TEST", SampleUnit.Second); using (Measure.Frames().Scope(sg)) { yield return(null); yield return(null); } var test = PerformanceTest.Active; Assert.AreEqual(1, test.SampleGroups.Count); Assert.AreEqual(test.SampleGroups[0].Samples.Count, 2); Assert.AreEqual(sg.Name, test.SampleGroups[0].Name); Assert.AreEqual(sg.Unit, test.SampleGroups[0].Unit); Assert.IsTrue(AllSamplesHigherThan0(test)); }
private SampleGroup LoadCategory(SampleSuite suite, string category, string prefix, string fileSourceCode) { SampleGroup categoryGroup = new SampleGroup(suite, category, null); Type suiteType = suite.GetType(); IEnumerable <MethodInfo> methodsInCategory = suiteType.GetMethods() .Where(c => c.Name.ToLower().StartsWith(prefix.ToLower())) .OrderBy(c => c.Name) .Select(c => new { Method = c, Attributes = (CategoryAttribute[])c.GetCustomAttributes(typeof(CategoryAttribute), false) }) .Where(c => c.Attributes.Length > 0 && c.Attributes[0].Category == category) .Select(c => c.Method); foreach (MethodInfo mi in methodsInCategory) { categoryGroup.Children.Add(LoadSample(suite, mi, fileSourceCode)); } return(categoryGroup); }
public void Sync_SampleGroup_Update_SampleGroupCode() { var fromPath = base.GetTempFilePath(".crz3", "SampleGroup_Update_SGCode_fromFile"); var toPath = base.GetTempFilePath(".crz3", "SampleGroup_Update_SGCode_toFile"); var syncOptions = new CruiseSyncOptions(); var cruiseID = Guid.NewGuid().ToString(); var saleID = Guid.NewGuid().ToString(); // initialize source database using var fromDb = CreateDatabaseFile(fromPath, cruiseID, saleID); var sampleGroupID = Guid.NewGuid().ToString(); var sampleGroup = new SampleGroup() { CruiseID = cruiseID, SampleGroupID = sampleGroupID, SampleGroupCode = "10", StratumCode = Strata[0].StratumCode, }; fromDb.Insert(sampleGroup); // initialize dest database // as exact copy of source database fromDb.CopyTo(toPath, true); using var toDb = new CruiseDatastore_V3(toPath); // modify sample group code on source database sampleGroup.SampleGroupCode = "11"; fromDb.Update(sampleGroup); // run sync var syncer = new CruiseSyncer(); syncer.Sync(cruiseID, fromDb, toDb, syncOptions); var sampleGroupAgain = toDb.From <SampleGroup>().Where("SampleGroupID = @p1") .Query(sampleGroupID).FirstOrDefault(); sampleGroupAgain.SampleGroupCode.Should().BeEquivalentTo(sampleGroup.SampleGroupCode); }
private void Form1_Load(object sender, EventArgs e) { _helper = new SampleHelper(panelSamples, panelSample, sampleHeader, sampleDescription); var samples = new AllSamples(); var g1 = new SampleGroup() { Name = "" }; var s11 = new Sample() { Name = "FlexChart Animation", Description = "Shows advanced animation options for FlexChart control.", ControlName = "FlexChartAnimation" }; g1.Samples.Add(s11); var s12 = new Sample() { Name = "FlexPie Animation", Description = "Shows advanced animation options for FlexPie control.", ControlName = "FlexPieAnimation" }; g1.Samples.Add(s12); var s13 = new Sample() { Name = "Custom Animation", Description = "Show how to customize animation with AnimationTransform event.", ControlName = "CustomAnimation" }; g1.Samples.Add(s13); samples.Groups.Add(g1); if (samples != null) { _helper.InitSamples(samples); } }
static void Main() { // set up a loader and source code search paths SampleLoader loader = new SampleLoader(); loader.AddSourceDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".")); loader.AddSourceDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Samples")); loader.AddSourceDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\Samples")); // load samples SampleGroup allSamples = new SampleGroup(null, "DotNumerics Samples", ""); allSamples.Children.Add(loader.Load(new LinearAlgebra())); allSamples.Children.Add(loader.Load(new DifferentialEquations())); allSamples.Children.Add(loader.Load(new Optimization())); Application.EnableVisualStyles(); Application.Run(new FormSampleRunner(allSamples)); }
public void MeasureMethod_WithCustomSampleGroup_And_ProfilerMarker_SetsTheCorrectSampleUnit_Run() { var sg = new SampleGroup("TEST", SampleUnit.Nanosecond); var sgMarker = new SampleGroup("TEST_MARKER", SampleUnit.Microsecond); Measure.Method(() => { MeasureProfilerSamplesTests.CreatePerformanceMarker("TEST_MARKER", 1); }) .SampleGroup(sg).ProfilerMarkers(sgMarker).Run(); var test = PerformanceTest.Active; Assert.AreEqual(2, test.SampleGroups.Count); Assert.AreEqual(sg.Unit, test.SampleGroups[0].Unit); Assert.AreEqual(sg.Name, test.SampleGroups[0].Name); Assert.AreEqual(sgMarker.Unit, test.SampleGroups[1].Unit); Assert.AreEqual(sgMarker.Name, test.SampleGroups[1].Name); Assert.Greater(test.SampleGroups[0].Samples.Count, 0); Assert.Greater(test.SampleGroups[1].Samples.Count, 0); //TODO: Add a way to override time so we can mock it and test if the conversion has been done. // Add to all the tests where we pass a SampleGroup. }
internal Tree CreateNewTreeEntryInternal(Stratum stratum , SampleGroup sg , TreeDefaultValueDO tdv , bool isMeasure) { Tree newTree = new Tree(DataStore) { TreeCount = 0, CountOrMeasure = (isMeasure) ? "M" : "C", CuttingUnit = CuttingUnit }; if (sg != null) { newTree.SampleGroup = sg; if (tdv == null) { if (sg.TreeDefaultValues.IsPopulated == false) { sg.TreeDefaultValues.Populate(); } if (sg.TreeDefaultValues.Count == 1) { tdv = sg.TreeDefaultValues.FirstOrDefault();//TODO should be SingleOrDefault } } } if (stratum != null) { newTree.Stratum = stratum; } if (tdv != null) { newTree.SetTreeTDV(tdv); } newTree.Validate(); //newTree.Save(); return(newTree); }
public void GetCountByHotKeyTest() { var stratum = new Stratum(); var counts = new CountTree[] { new CountTree() { Tally = new TallyDO() { Hotkey = "A" } }, new CountTree() { Tally = new TallyDO() { Hotkey = "Banana" } }, new CountTree() { Tally = new TallyDO() { Hotkey = "cat" } } }; var samplegroups = new SampleGroup[] { new SampleGroup() { Counts = counts } }; stratum.SampleGroups = new List <SampleGroup>(samplegroups); stratum.GetCountByHotKey('A').Should().Be(counts[0]); stratum.GetCountByHotKey('B').Should().Be(counts[1]); stratum.GetCountByHotKey('C').Should().Be(counts[2]); stratum.GetCountByHotKey('0').Should().BeNull(); }
private TreeNode CreateTreeNode(SampleBase sample, int level) { TreeNode node = new TreeNode(sample.Title); node.Tag = sample; SampleGroup sg = sample as SampleGroup; if (sg != null) { foreach (SampleBase sb in sg.Children) { node.Nodes.Add(CreateTreeNode(sb, level + 1)); } node.ImageKey = node.SelectedImageKey = "BookClosed"; } else { node.ImageKey = node.SelectedImageKey = "Item"; } return(node); }
public FormSampleRunner(SampleGroup rootSampleGroup) { InitializeComponent(); Text = rootSampleGroup.Title; ObjectDumper dumper = new ObjectDumper(); dumper.TreeView = treeViewOutput; dumper.OutputTextBox = outputTextBox; dumper.GeneratedSqlTextBox = traceTextBox; dumper.GeneratedVfpTextBox = vfpTraceTextBox; _runner = new SampleRunnerImpl(this, dumper); TreeNode rootNode = CreateTreeNode(rootSampleGroup, 0); rootNode.ImageKey = rootNode.SelectedImageKey = "Help"; samplesTreeView.Nodes.Add(rootNode); rootNode.Expand(); }
// [UnityTest] // [UseGltfSampleSetTestCase(localSampleSetJsonPath)] // [Performance] // public IEnumerator UninterruptedLoadingLocal(SampleSetItem testCase) { // yield return UninterruptedLoadingTemplate(testCase); // } static IEnumerator UninterruptedLoadingTemplate(SampleSetItem testCase) { Debug.Log($"Testing {testCase.path}"); var go = new GameObject(); var deferAgent = new UninterruptedDeferAgent(); var loadTime = new SampleGroup("LoadTime"); // First time without measuring var task = SampleModelsTest.LoadGltfSampleSetItem(testCase, go, deferAgent, loadTime); yield return(Utils.WaitForTask(task)); using (Measure.Frames().Scope()) { for (int i = 0; i < k_Repetitions; i++) { task = SampleModelsTest.LoadGltfSampleSetItem(testCase, go, deferAgent, loadTime); yield return(Utils.WaitForTask(task)); } } Object.Destroy(go); }
public Tree UserAddTree() { Tree templateTree = NonPlotTrees.LastOrDefault(); Stratum stratum = null; SampleGroup samplegroup = null; TreeDefaultValueDO tdv = null; if (templateTree != null) { stratum = templateTree.Stratum; samplegroup = templateTree.SampleGroup; tdv = templateTree.TreeDefaultValue; } else if (DefaultStratum != null) { stratum = this.DefaultStratum; //var samplegroups = DAL.From<SampleGroupModel>() // .Where("Stratum_CN = ?") // .Read(stratum.Stratum_CN).ToList(); if (stratum.SampleGroups != null && stratum.SampleGroups.Count == 1) { samplegroup = stratum.SampleGroups[0]; } } var newTree = CreateNewTreeEntry(stratum , samplegroup, tdv, true); newTree.TreeCount = 0; //user added trees need a tree count of zero because users seem to be adding counts through tally settings DialogService.AskCruiser(newTree); newTree.TrySave(); AddNonPlotTree(newTree); return(newTree); }
public Tree UserAddTree(Plot plot, Tree templateTree) { Tree newTree; SampleGroup assumedSG = null; TreeDefaultValueDO assumedTDV = null; if (templateTree != null) { assumedSG = templateTree.SampleGroup; assumedTDV = templateTree.TreeDefaultValue; } //extrapolate sample group if (assumedSG == null)//if we have a stratum but no sample group, pick the first one { List <SampleGroup> samplegroups = DataStore.From <SampleGroup>() .Where("Stratum_CN = @p1") .Read(plot.Stratum.Stratum_CN).ToList(); if (samplegroups.Count == 1) { assumedSG = samplegroups[0]; } } newTree = this.CreateNewTreeEntry(plot, assumedSG, assumedTDV, true); //if a 3P plot method set Count Measure to empty. if (Array.IndexOf(CruiseDAL.Schema.CruiseMethods.THREE_P_METHODS, plot.Stratum.Method) >= 0) { newTree.CountOrMeasure = string.Empty; } newTree.TreeCount = 1; //user added trees need a tree count of one because they aren't being tallied newTree.TrySave(); plot.AddTree(newTree); return(newTree); }
public void SyncDesign_Test_PullSamplegroups() { var(master, comps) = MakeFiles(numComponents: 2); var compVMs = comps.Select((x, i) => { return(new ComponentFile() { Database = x, Component_CN = i }); }) .ToArray(); var comp1 = comps.First(); var comp1Sg1 = new SampleGroup() { Stratum_CN = 1, Code = "nsg1", PrimaryProduct = "01", CutLeave = "C", UOM = "01", }; comp1.Insert(comp1Sg1, keyValue: 1000); MergeSyncWorker.SyncDesign( master, compVMs, new System.Threading.CancellationToken(), (IProgress <int>)null, TestMergeLogWriter); var mastSg1 = master.From <SampleGroup>().Where("Code = @p1").Query("nsg1").FirstOrDefault(); ValidateSgSame(mastSg1, comp1Sg1); var comp2 = comps.ElementAt(1); var comp2Sg2 = comp2.From <SampleGroup>().Where("Code = @p1").Query("nsg1").FirstOrDefault(); ValidateSgSame(comp2Sg2, comp1Sg1); }
public void CreateRandomEvents([Values(5, 25, 100, 1000)] int eventsPerArchetype, [Values(1, 10, 50, 100)] int archetypeCount) { var system = Manager.World.GetOrCreateSystem <LoadTestSystem>(); var eMin = 1; var eMax = eventsPerArchetype; var aMin = 1; var aMax = archetypeCount; var group = new SampleGroup($"Random entity counts between [{eMin}-{eMax}], and [{aMin}-{aMax}] archetypes", SampleUnit.Millisecond); var measurements = 25; var warmups = 5; var sw = new Stopwatch(); for (int i = 0; i < measurements; i++) { if (i < warmups) { system.EventsPerArchetype = UnityEngine.Random.Range(eMin, eMax); system.ArchetypeCount = UnityEngine.Random.Range(aMin, aMax); system.Update(); EventSystem.Update(); } else { system.EventsPerArchetype = UnityEngine.Random.Range(eMin, eMax); system.ArchetypeCount = UnityEngine.Random.Range(aMin, aMax); system.Update(); sw.Restart(); EventSystem.Update(); sw.Stop(); Measure.Custom(group, sw.Elapsed.TotalMilliseconds); } } }
public void TallyThreePTest_STM() { int expectedKPI = -1;//when kpi is -1, kpi entered was STM int minKPI = 101; int maxKPI = 102; var dialogServiceMock = new Mock <IDialogService>(); dialogServiceMock.Setup(ds => ds.AskKPI(It.Is <int>(x => x == minKPI), It.Is <int>(x => x == maxKPI), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(expectedKPI); var sg = new SampleGroup() { MinKPI = minKPI, MaxKPI = maxKPI }; var count = new CountTree() { TreeCount = 0, SumKPI = 0 }; var sampleSelector = new FMSC.Sampling.ThreePSelecter(1, 0); var expectedTree = new Tree(); var dataServiceMock = new Moq.Mock <ITreeDataService>(); dataServiceMock.Setup(ds => ds.CreateNewTreeEntry(It.IsAny <CountTree>())).Returns(expectedTree); var result = FormDataEntryLogic.TallyThreeP(count, sampleSelector, sg, dataServiceMock.Object, dialogServiceMock.Object); result.Should().NotBeNull(); result.TreeRecord.Should().BeSameAs(expectedTree); result.Count.Should().BeSameAs(count); result.KPI.Should().Be(0); result.TreeCount.Should().Be(1); expectedTree.CountOrMeasure.Should().BeNull(); expectedTree.STM = "Y"; }
public IEnumerator SmoothLoading(SampleSetItem testCase) { Debug.Log($"Testing {testCase.path}"); var go = new GameObject(); var deferAgent = go.AddComponent <TimeBudgetPerFrameDeferAgent>(); SampleGroup loadTime = new SampleGroup("LoadTime"); // First time without measuring var task = SampleModelsTest.LoadGltfSampleSetItem(testCase, go, deferAgent); yield return(Utils.WaitForTask(task)); using (Measure.Frames().Scope()) { for (int i = 0; i < k_Repetitions; i++) { task = SampleModelsTest.LoadGltfSampleSetItem(testCase, go, deferAgent, loadTime); yield return(Utils.WaitForTask(task)); // Wait one more frame. Usually some more action happens in this one. yield return(null); } } Object.Destroy(go); }
public virtual Tree CreateNewTreeEntry(Plot plot, SampleGroup sg, TreeDefaultValueDO tdv, bool isMeasure) { Debug.Assert(plot.CuttingUnit != null); if (plot is FixCNTPlot) { isMeasure = false; } var newTree = CreateNewTreeEntryInternal(plot.Stratum, sg, tdv, isMeasure); newTree.Plot = plot; if (IsReconCruise) { newTree.TreeNumber = GetNextTreeNumber(plot.Trees); } else { newTree.TreeNumber = GetNextPlotTreeNumber(plot.PlotNumber); } newTree.TreeCount = 1; return(newTree); }
public override void OnFinishedGroup(SampleGroup group) { }
public override void OnStartingGroup(SampleGroup group) { }