Last active
February 25, 2020 02:10
-
-
Save jeffvella/e7a2b912cded1fb52d662b60358003c9 to your computer and use it in GitHub Desktop.
:D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int count; | |
| int* countPtr = &count; | |
| NativeKeyValueArrays<int, UnsafeEventBatch> pairsMaster = default; | |
| NativeArray<Entity> entitiesMaster = default; | |
| var pairsPtr = UnsafeUtility.AddressOf(ref pairsMaster); | |
| var entitiesPtr = UnsafeUtility.AddressOf(ref entitiesMaster); | |
| var sw = Stopwatch.StartNew(); | |
| Job.WithCode(() => | |
| { | |
| ref var pairs = ref UnsafeUtilityEx.AsRef<NativeKeyValueArrays<int, UnsafeEventBatch>>(pairsPtr); | |
| ref var entities = ref UnsafeUtilityEx.AsRef<NativeArray<Entity>>(entitiesPtr); | |
| pairs = map.GetKeyValueArrays(Allocator.Temp); | |
| for (int i = 0; i < pairs.Keys.Length; i++) | |
| { | |
| var batchCount = pairs.Values[i].Queue.Count(); | |
| *countPtr += batchCount; | |
| } | |
| entities = new NativeArray<Entity>(*countPtr, Allocator.TempJob); | |
| }).Run(); | |
| sw.Stop(); | |
| Debug.Log($"Time={sw.Elapsed.TotalMilliseconds:N4}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment