public void TearDown() { m_PlanGraph.Dispose(); }
public void MatchManyExistingStates() { const int kRootState = 0; const int kActionCount = 1000; PlanGraph <int, StateInfo, int, ActionInfo, StateTransitionInfo> planGraph = default; NativeMultiHashMap <int, int> binnedStateKeys = default; NativeQueue <int> newStatesQueue = default; NativeList <StateTransitionInfoPair <int, int, StateTransitionInfo> > statesToProcess = default; NativeQueue <int> newStatesToDestroy = default; Measure.Method(() => { var stateTransitionInfoLookup = planGraph.StateTransitionInfoLookup; var resultingStateLookup = planGraph.ResultingStateLookup; var expansionJob = new GraphExpansionJob <int, int, TestStateDataContext, int> { BinnedStateKeys = binnedStateKeys, NewStateTransitionInfoPairs = statesToProcess.AsDeferredJobArray(), ActionLookup = planGraph.ActionLookup.AsParallelWriter(), ActionInfoLookup = planGraph.ActionInfoLookup.AsParallelWriter(), StateTransitionInfoLookup = stateTransitionInfoLookup.AsParallelWriter(), ResultingStateLookup = resultingStateLookup.AsParallelWriter(), NewStates = newStatesQueue.AsParallelWriter(), PredecessorGraph = planGraph.PredecessorGraph.AsParallelWriter(), StateDataContext = new TestStateDataContext(), StatesToDestroy = newStatesToDestroy.AsParallelWriter(), }; expansionJob.Schedule(statesToProcess, default).Complete(); }).SetUp(() => { // One root node and all children nodes of a single depth planGraph = PlanGraphUtility.BuildTree(kActionCount, 1, 1); planGraph.ExpandBy(kActionCount, kActionCount); newStatesQueue = new NativeQueue <int>(Allocator.TempJob); newStatesToDestroy = new NativeQueue <int>(Allocator.TempJob); // Extend graph by one depth with the same number of actions / resulting states that loop back on themselves statesToProcess = new NativeList <StateTransitionInfoPair <int, int, StateTransitionInfo> >(kActionCount, Allocator.TempJob); for (var i = 0; i < kActionCount; i++) { statesToProcess.Add(new StateTransitionInfoPair <int, int, StateTransitionInfo>(kRootState, i, i, new StateTransitionInfo() { Probability = 1, TransitionUtilityValue = 1 })); } binnedStateKeys = GetBinnedStateKeys(planGraph); }).CleanUp(() => { planGraph.Dispose(); newStatesQueue.Dispose(); statesToProcess.Dispose(); binnedStateKeys.Dispose(); newStatesToDestroy.Dispose(); }).WarmupCount(1).MeasurementCount(30).IterationsPerMeasurement(1).Run(); PerformanceUtility.AssertRange(4.3, 6.25); }