├── .gitattributes ├── ProjectSettings ├── ProjectVersion.txt ├── CommonBurstAotSettings.json ├── Packages │ └── com.unity.testtools.codecoverage │ │ └── Settings.json ├── ClusterInputManager.asset ├── PresetManager.asset ├── EditorBuildSettings.asset ├── XRSettings.asset ├── VersionControlSettings.asset ├── TimeManager.asset ├── VFXManager.asset ├── BurstAotSettings_StandaloneOSX.json ├── AudioManager.asset ├── TagManager.asset ├── PackageManagerSettings.asset ├── UnityConnectSettings.asset ├── DynamicsManager.asset ├── MemorySettings.asset ├── EditorSettings.asset ├── NavMeshAreas.asset ├── Physics2DSettings.asset ├── GraphicsSettings.asset ├── SceneTemplateSettings.json ├── InputManager.asset └── QualitySettings.asset ├── Assets ├── BurstLinq │ ├── Documentation~ │ │ └── img1.png │ ├── package.json.meta │ ├── Runtime.meta │ ├── Tests.meta │ ├── Tests │ │ ├── Runtime │ │ │ ├── AverageTest.tt.meta │ │ │ ├── MaxTest.tt.meta │ │ │ ├── MinTest.tt.meta │ │ │ ├── SumTest.tt.meta │ │ │ ├── SequenceEqualTest.tt.meta │ │ │ ├── BurstLinq.Tests.Runtime.asmdef.meta │ │ │ ├── AssertEx.cs.meta │ │ │ ├── Benchmark.cs.meta │ │ │ ├── MaxTest.cs.meta │ │ │ ├── MinTest.cs.meta │ │ │ ├── SumTest.cs.meta │ │ │ ├── AverageTest.cs.meta │ │ │ ├── ContainsTest.cs.meta │ │ │ ├── RandomEnumerable.cs.meta │ │ │ ├── SequenceEqualTest.cs.meta │ │ │ ├── BurstLinq.Tests.Runtime.asmdef │ │ │ ├── MaxTest.tt │ │ │ ├── MinTest.tt │ │ │ ├── ContainsTest.cs │ │ │ ├── SequenceEqualTest.tt │ │ │ ├── AssertEx.cs │ │ │ ├── SumTest.tt │ │ │ ├── AverageTest.tt │ │ │ ├── MaxTest.cs │ │ │ ├── MinTest.cs │ │ │ ├── Benchmark.cs │ │ │ ├── AverageTest.cs │ │ │ └── SumTest.cs │ │ └── Runtime.meta │ ├── Runtime │ │ ├── BurstLinq.asmdef.meta │ │ ├── BurstLinqExtensions.Average.tt.meta │ │ ├── BurstLinqExtensions.Max.tt.meta │ │ ├── BurstLinqExtensions.Min.tt.meta │ │ ├── BurstLinqExtensions.Sum.tt.meta │ │ ├── BurstLinqExtensions.Contains.tt.meta │ │ ├── BurstLinqExtensions.Native.Max.tt.meta │ │ ├── BurstLinqExtensions.Native.Min.tt.meta │ │ ├── BurstLinqExtensions.Native.Sum.tt.meta │ │ ├── BurstLinqExtensions.Native.Average.tt.meta │ │ ├── BurstLinqExtensions.Native.Contains.tt.meta │ │ ├── BurstLinqExtensions.SequenceEqual.tt.meta │ │ ├── BurstLinqExtensions.Native.SequenceEqual.tt.meta │ │ ├── BurstLinqExtensions.cs │ │ ├── Error.cs.meta │ │ ├── CmpHelpers.cs.meta │ │ ├── SpanHelper.cs.meta │ │ ├── Vectors.cs.meta │ │ ├── BurstHelpers.cs.meta │ │ ├── BurstLinqExtensions.cs.meta │ │ ├── BurstLinqExtensions.Max.cs.meta │ │ ├── BurstLinqExtensions.Min.cs.meta │ │ ├── BurstLinqExtensions.Sum.cs.meta │ │ ├── BurstLinqExtensions.Average.cs.meta │ │ ├── BurstLinqExtensions.Contains.cs.meta │ │ ├── BurstLinqExtensions.Native.Max.cs.meta │ │ ├── BurstLinqExtensions.Native.Min.cs.meta │ │ ├── BurstLinqExtensions.Native.Sum.cs.meta │ │ ├── BurstLinqExtensions.Native.Average.cs.meta │ │ ├── BurstLinqExtensions.Native.Contains.cs.meta │ │ ├── BurstLinqExtensions.SequenceEqual.cs.meta │ │ ├── BurstLinqExtensions.Native.SequenceEqual.cs.meta │ │ ├── BurstHelpers.cs │ │ ├── BurstLinq.asmdef │ │ ├── Error.cs │ │ ├── SpanHelper.cs │ │ ├── BurstLinqExtensions.Max.tt │ │ ├── BurstLinqExtensions.Min.tt │ │ ├── BurstLinqExtensions.Sum.tt │ │ ├── BurstLinqExtensions.Contains.tt │ │ ├── BurstLinqExtensions.Native.Average.tt │ │ ├── BurstLinqExtensions.Native.SequenceEqual.tt │ │ ├── BurstLinqExtensions.Native.Sum.tt │ │ ├── CmpHelpers.cs │ │ ├── BurstLinqExtensions.Average.tt │ │ ├── BurstLinqExtensions.Native.Min.tt │ │ ├── BurstLinqExtensions.Native.Max.tt │ │ ├── BurstLinqExtensions.SequenceEqual.tt │ │ ├── BurstLinqExtensions.Native.Contains.tt │ │ └── Vectors.cs │ └── package.json └── BurstLinq.meta ├── LICENSE ├── .gitignore ├── Packages ├── manifest.json └── packages-lock.json ├── README_JA.md └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2022.3.7f1 2 | m_EditorVersionWithRevision: 2022.3.7f1 (b16b3b16c7a0) 3 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Documentation~/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/annulusgames/BurstLinq/HEAD/Assets/BurstLinq/Documentation~/img1.png -------------------------------------------------------------------------------- /ProjectSettings/CommonBurstAotSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 4, 4 | "DisabledWarnings": "" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "m_Dictionary": { 3 | "m_DictionaryValues": [] 4 | } 5 | } -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f0678f7ba168481590801edce899326 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0bc2035faf064fc9b39816314a001d7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bcb9141eec5a6493d8e1f71aea2aac29 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ed136c7d2231406f954843969852723 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/AverageTest.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7d1190a97bce4842b286021d8796d4d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/MaxTest.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0407dc155148540d5a8ad6a1a9695d9c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/MinTest.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56d0dea43820d4f1fa307da050280f15 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/SumTest.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b60ef8315855e4099ac7d5322be6a5c4 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinq.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75a4edf3e29b24eacad77b2b175d4d8f 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Average.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21e144b8b72bb4e0f842d711c313d4c4 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Max.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 689524d35dd334b42bdcb35388d0cd48 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Min.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89ff07cc368864015b25aad430a8b665 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Sum.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 740008369ba8d4a3381adaa087070605 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 015f9dfd74a6549a8ba6973215bdec35 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/SequenceEqualTest.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7566cc4bcab64f6d844a81af29ff526 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Contains.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09d9091d25ab146cd83aa6bd009f5fb9 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Max.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 893b1e940b35d42019993a688cd20bf2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Min.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2aec1a558601c493da363c3c64bef216 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Sum.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1cdd06228afb942f78b23c4dca6c4e47 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Average.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e45c49a2aa40348b685f1b45af887076 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Contains.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13b5d1c751c4848cd81a19097cbdb5a6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.SequenceEqual.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46ad07dd69d15432eadcd6ca697f2a5b 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.SequenceEqual.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d651c44abf06842ebaaa5b82e3471072 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | 3 | namespace BurstLinq 4 | { 5 | [BurstCompile(OptimizeFor = OptimizeFor.Performance)] 6 | public static partial class BurstLinqExtensions 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/BurstLinq.Tests.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3091443d419f943faae76bebd1e7ac5f 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/Error.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 947a1f13c914d44aebc6da923dd1c657 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/CmpHelpers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e727f3cb65621412f8927f011e760a82 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/SpanHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7723c8bdc26dc44c3934d82af7ee3843 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/Vectors.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f2d942b28d6b4a7c9962b2614ef9190 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstHelpers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 617908ec85574495e82cbe33f5fa3c3a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/AssertEx.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e5dd188b1cd44c4ead7c1aa8da6ae4d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/Benchmark.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d39bdb98ccf048429c5c1c5a933bc6f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/MaxTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37fd8c825ce154f449e852fea235633e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/MinTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09b6c4f1dba244af19367d039be910f7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/SumTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4294f56768c24a19aef47ed0630569c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66be7336c90984baaab6a9756a847e1a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/AverageTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28462f0a22ab54b8eb216473e8105c23 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/ContainsTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c667f33a822124332b2f9d372526724e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Max.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b45de311116c143618fe3131431441f3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Min.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd1e1e3cb6ec34036bcba189c14dce1a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Sum.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f6fa0c26972249c2a78d5cc0d4336fe 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/RandomEnumerable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ba11c532da2d473b8b8076083d9ff6a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/SequenceEqualTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94d745d244014480caeeb7ce8941916e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Average.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78fa11b0b39df45cf92985561e609461 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Contains.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9eb388d44f6c4009b8413bbef734ae2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Max.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf9842e279ad54c088165db4c0c98505 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Min.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de88d273ca0384b83950cbdeff2ade41 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Sum.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 714495b51e8264155bb1ccf1c6283ebb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Average.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9395d12cf09894920aa7da73fea1d6ea 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Contains.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7373cb17d160e40e9a94e729f79067b4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.SequenceEqual.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 688ab54d59cb2489b83bc2571ea87c9e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.SequenceEqual.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0ccd9adadecb4bb7b6683997e98cbe7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /Assets/BurstLinq/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.annulusgames.burst-linq", 3 | "version": "1.2.0", 4 | "displayName": "Burst Linq", 5 | "description": "Extremely fast LINQ aggregation operations implementation optimized by Burst Compiler", 6 | "unity": "2020.1", 7 | "author": { 8 | "name": "Annulus Games", 9 | "url": "https://github.com/AnnulusGames" 10 | } 11 | } -------------------------------------------------------------------------------- /ProjectSettings/BurstAotSettings_StandaloneOSX.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 4, 4 | "EnableBurstCompilation": true, 5 | "EnableOptimisations": true, 6 | "EnableSafetyChecks": false, 7 | "EnableDebugInAllBuilds": false, 8 | "DebugDataKind": 1, 9 | "EnableArmv9SecurityFeatures": false, 10 | "CpuMinTargetX32": 0, 11 | "CpuMaxTargetX32": 0, 12 | "CpuMinTargetX64": 0, 13 | "CpuMaxTargetX64": 0, 14 | "CpuTargetsX64": 72, 15 | "OptimizeFor": 0 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstHelpers.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst.Intrinsics; 2 | 3 | namespace BurstLinq 4 | { 5 | internal static unsafe class BurstHelpers 6 | { 7 | internal static bool IsFloatingPoint256Supported => X86.Avx.IsAvxSupported; 8 | internal static bool IsInteger256Supported => X86.Avx2.IsAvx2Supported; 9 | internal static bool IsV256Supported => X86.Avx2.IsAvx2Supported; 10 | internal static bool IsV128Supported => Arm.Neon.IsNeonSupported||X86.Sse4_1.IsSse41Supported; 11 | } 12 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinq.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BurstLinq", 3 | "rootNamespace": "BurstLinq", 4 | "references": [ 5 | "GUID:e0cd26848372d4e5c891c569017e11f1", 6 | "GUID:2665a8d13d1b3f18800f46e256720795", 7 | "GUID:d8b63aba1907145bea998dd612889d6b" 8 | ], 9 | "includePlatforms": [], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": true, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/BurstLinq.Tests.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BurstLinq.Tests.Runtime", 3 | "rootNamespace": "BurstLinq.Tests", 4 | "references": [ 5 | "UnityEngine.TestRunner", 6 | "UnityEditor.TestRunner", 7 | "Unity.PerformanceTesting", 8 | "Unity.Mathematics", 9 | "Unity.Collections", 10 | "BurstLinq" 11 | ], 12 | "includePlatforms": [], 13 | "excludePlatforms": [], 14 | "allowUnsafeCode": false, 15 | "overrideReferences": true, 16 | "precompiledReferences": [ 17 | "nunit.framework.dll" 18 | ], 19 | "autoReferenced": false, 20 | "defineConstraints": [ 21 | "UNITY_INCLUDE_TESTS" 22 | ], 23 | "versionDefines": [], 24 | "noEngineReferences": false 25 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/Error.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | 4 | namespace BurstLinq 5 | { 6 | internal static class Error 7 | { 8 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 9 | public static void ThrowIfNull(T obj) 10 | { 11 | if (obj == null) throw new ArgumentNullException(); 12 | } 13 | 14 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 15 | public static void ThrowIfEmpty(int length) 16 | { 17 | if (length <= 0) throw new InvalidOperationException("Sequence contains no elements"); 18 | } 19 | 20 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 21 | public static void ThrowIfEmpty(bool isEmpty) 22 | { 23 | if (isEmpty) throw new InvalidOperationException("Sequence contains no elements"); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreReleasePackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | m_SeeAllPackageVersions: 0 20 | oneTimeWarningShown: 0 21 | m_Registries: 22 | - m_Id: main 23 | m_Name: 24 | m_Url: https://packages.unity.com 25 | m_Scopes: [] 26 | m_IsDefault: 1 27 | m_Capabilities: 7 28 | m_UserSelectedRegistryName: 29 | m_UserAddingNewScopedRegistry: 0 30 | m_RegistryInfoDraft: 31 | m_Modified: 0 32 | m_ErrorMessage: 33 | m_UserModificationsInstanceId: -830 34 | m_OriginalInstanceId: -832 35 | m_LoadAssets: 0 36 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | m_PackageRequiringCoreStatsPresent: 0 27 | UnityAdsSettings: 28 | m_Enabled: 0 29 | m_InitializeOnStartup: 1 30 | m_TestMode: 0 31 | m_IosGameId: 32 | m_AndroidGameId: 33 | m_GameIds: {} 34 | m_GameId: 35 | PerformanceReportingSettings: 36 | m_Enabled: 0 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Annulus Games 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/SpanHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using Unity.Burst; 5 | using Unity.Collections; 6 | using Unity.Collections.LowLevel.Unsafe; 7 | 8 | namespace BurstLinq 9 | { 10 | // Class for extracting the contents of List with UnsafeUtility.As 11 | internal sealed class ListView 12 | { 13 | public T[] _items; 14 | } 15 | 16 | [BurstCompile] 17 | internal static class SpanHelper 18 | { 19 | [BurstCompile] 20 | public static unsafe void CopyFrom(in NativeArray array, in ReadOnlySpan source) 21 | where T : unmanaged 22 | { 23 | CheckLength(source.Length, array.Length); 24 | void* dstPtr = array.GetUnsafePtr(); 25 | 26 | fixed (void* srcPtr = source) 27 | { 28 | UnsafeUtility.MemCpy(dstPtr, srcPtr, array.Length * UnsafeUtility.SizeOf()); 29 | } 30 | } 31 | 32 | public static Span AsSpan(List list) where T : unmanaged 33 | { 34 | ref var view = ref UnsafeUtility.As, ListView>(ref list); 35 | return view._items.AsSpan(0, list.Count); 36 | } 37 | 38 | [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] 39 | static void CheckLength(int srcLength, int dstLength) 40 | { 41 | if (srcLength != dstLength) throw new ArgumentException("source and destination length must be the same"); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.unitypackage 62 | *.app 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | # Packed Addressables 68 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 69 | 70 | # Temporary auto-generated Android Assets 71 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 72 | /[Aa]ssets/[Ss]treamingAssets/aa/* 73 | 74 | # Visual Studio Code cache directory 75 | .vscode/ 76 | 77 | # DS_Store 78 | *.DS_Store -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_SerializationMode: 2 8 | m_LineEndingsForNewScripts: 0 9 | m_DefaultBehaviorMode: 0 10 | m_PrefabRegularEnvironment: {fileID: 0} 11 | m_PrefabUIEnvironment: {fileID: 0} 12 | m_SpritePackerMode: 0 13 | m_SpritePackerCacheSize: 10 14 | m_SpritePackerPaddingPower: 1 15 | m_Bc7TextureCompressor: 0 16 | m_EtcTextureCompressorBehavior: 1 17 | m_EtcTextureFastCompressor: 1 18 | m_EtcTextureNormalCompressor: 2 19 | m_EtcTextureBestCompressor: 4 20 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 21 | m_ProjectGenerationRootNamespace: 22 | m_EnableTextureStreamingInEditMode: 1 23 | m_EnableTextureStreamingInPlayMode: 1 24 | m_EnableEditorAsyncCPUTextureLoading: 0 25 | m_AsyncShaderCompilation: 1 26 | m_PrefabModeAllowAutoSave: 1 27 | m_EnterPlayModeOptionsEnabled: 1 28 | m_EnterPlayModeOptions: 3 29 | m_GameObjectNamingDigits: 1 30 | m_GameObjectNamingScheme: 0 31 | m_AssetNamingUsesSpace: 1 32 | m_InspectorUseIMGUIDefaultInspector: 0 33 | m_UseLegacyProbeSampleCount: 0 34 | m_SerializeInlineMappingsOnOneLine: 1 35 | m_DisableCookiesInLightmapper: 0 36 | m_AssetPipelineMode: 1 37 | m_RefreshImportMode: 0 38 | m_CacheServerMode: 0 39 | m_CacheServerEndpoint: 40 | m_CacheServerNamespacePrefix: default 41 | m_CacheServerEnableDownload: 1 42 | m_CacheServerEnableUpload: 1 43 | m_CacheServerEnableAuth: 0 44 | m_CacheServerEnableTls: 0 45 | m_CacheServerValidationMode: 2 46 | m_CacheServerDownloadBatchSize: 128 47 | m_EnableEnlightenBakedGI: 0 48 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "2.2.0", 4 | "com.unity.collections": "2.1.4", 5 | "com.unity.feature.development": "1.0.1", 6 | "com.unity.ide.visualstudio": "2.0.22", 7 | "com.unity.test-framework.performance": "3.0.3", 8 | "com.unity.textmeshpro": "3.0.6", 9 | "com.unity.timeline": "1.7.5", 10 | "com.unity.toolchain.macos-arm64-linux-x86_64": "2.0.0", 11 | "com.unity.ugui": "1.0.0", 12 | "com.unity.visualscripting": "1.8.0", 13 | "com.unity.modules.ai": "1.0.0", 14 | "com.unity.modules.androidjni": "1.0.0", 15 | "com.unity.modules.animation": "1.0.0", 16 | "com.unity.modules.assetbundle": "1.0.0", 17 | "com.unity.modules.audio": "1.0.0", 18 | "com.unity.modules.cloth": "1.0.0", 19 | "com.unity.modules.director": "1.0.0", 20 | "com.unity.modules.imageconversion": "1.0.0", 21 | "com.unity.modules.imgui": "1.0.0", 22 | "com.unity.modules.jsonserialize": "1.0.0", 23 | "com.unity.modules.particlesystem": "1.0.0", 24 | "com.unity.modules.physics": "1.0.0", 25 | "com.unity.modules.physics2d": "1.0.0", 26 | "com.unity.modules.screencapture": "1.0.0", 27 | "com.unity.modules.terrain": "1.0.0", 28 | "com.unity.modules.terrainphysics": "1.0.0", 29 | "com.unity.modules.tilemap": "1.0.0", 30 | "com.unity.modules.ui": "1.0.0", 31 | "com.unity.modules.uielements": "1.0.0", 32 | "com.unity.modules.umbra": "1.0.0", 33 | "com.unity.modules.unityanalytics": "1.0.0", 34 | "com.unity.modules.unitywebrequest": "1.0.0", 35 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 36 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 37 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 38 | "com.unity.modules.unitywebrequestwww": "1.0.0", 39 | "com.unity.modules.vehicles": "1.0.0", 40 | "com.unity.modules.video": "1.0.0", 41 | "com.unity.modules.vr": "1.0.0", 42 | "com.unity.modules.wind": "1.0.0", 43 | "com.unity.modules.xr": "1.0.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/MaxTest.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | string GetTypeName(string typeName) 9 | { 10 | if (typeName[0] == 'u') return "U" + char.ToUpper(typeName[1]) + typeName.Substring(2); 11 | if (typeName == "sbyte") return "SByte"; 12 | return char.ToUpper(typeName[0]) + typeName.Substring(1); 13 | } 14 | 15 | var types = new string[] 16 | { 17 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double" 18 | }; 19 | #> 20 | using System; 21 | using System.Linq; 22 | using NUnit.Framework; 23 | using Assert = UnityEngine.Assertions.Assert; 24 | using Random = UnityEngine.Random; 25 | 26 | namespace BurstLinq.Tests 27 | { 28 | public class MaxTest 29 | { 30 | [SetUp] 31 | public void SetUp() 32 | { 33 | Random.InitState((int)DateTime.Now.Ticks); 34 | } 35 | 36 | [Test] 37 | public void Test_List() 38 | { 39 | for (int i = 0; i < 1000; i++) 40 | { 41 | var list = RandomEnumerable.RepeatInt(0, 100, 1000).ToList(); 42 | 43 | var result1 = Enumerable.Max(list); 44 | var result2 = BurstLinqExtensions.Max(list); 45 | 46 | Assert.AreEqual(result1, result2); 47 | } 48 | } 49 | 50 | <# foreach(var type in types) { #> 51 | [Test] 52 | public void Test_Array_<#=GetTypeName(type)#>() 53 | { 54 | for (int i = 0; i < 1000; i++) 55 | { 56 | var array = RandomEnumerable.Repeat<#=GetTypeName(type)#>(0, 100, 1000).ToArray(); 57 | 58 | var result1 = Enumerable.Max(array); 59 | var result2 = BurstLinqExtensions.Max(array); 60 | 61 | Assert.AreEqual(result1, result2); 62 | } 63 | } 64 | 65 | <# } #> 66 | } 67 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/MinTest.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | string GetTypeName(string typeName) 9 | { 10 | if (typeName[0] == 'u') return "U" + char.ToUpper(typeName[1]) + typeName.Substring(2); 11 | if (typeName == "sbyte") return "SByte"; 12 | return char.ToUpper(typeName[0]) + typeName.Substring(1); 13 | } 14 | 15 | var types = new string[] 16 | { 17 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double" 18 | }; 19 | #> 20 | using System; 21 | using System.Linq; 22 | using NUnit.Framework; 23 | using Assert = UnityEngine.Assertions.Assert; 24 | using Random = UnityEngine.Random; 25 | 26 | namespace BurstLinq.Tests 27 | { 28 | public class MinTest 29 | { 30 | [SetUp] 31 | public void SetUp() 32 | { 33 | Random.InitState((int)DateTime.Now.Ticks); 34 | } 35 | 36 | [Test] 37 | public void Test_List() 38 | { 39 | for (int i = 0; i < 1000; i++) 40 | { 41 | var list = RandomEnumerable.RepeatInt(0, 100, 1000).ToList(); 42 | 43 | var result1 = Enumerable.Min(list); 44 | var result2 = BurstLinqExtensions.Min(list); 45 | 46 | Assert.AreEqual(result1, result2); 47 | } 48 | } 49 | 50 | <# foreach(var type in types) { #> 51 | [Test] 52 | public void Test_Array_<#=GetTypeName(type)#>() 53 | { 54 | for (int i = 0; i < 1000; i++) 55 | { 56 | var array = RandomEnumerable.Repeat<#=GetTypeName(type)#>(0, 100, 1000).ToArray(); 57 | 58 | var result1 = Enumerable.Min(array); 59 | var result2 = BurstLinqExtensions.Min(array); 60 | 61 | Assert.AreEqual(result1, result2); 62 | } 63 | } 64 | 65 | <# } #> 66 | } 67 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/ContainsTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Runtime.InteropServices; 4 | using NUnit.Framework; 5 | using UnityEngine; 6 | using Assert = UnityEngine.Assertions.Assert; 7 | using Random = UnityEngine.Random; 8 | 9 | namespace BurstLinq.Tests 10 | { 11 | public class ContainsTest 12 | { 13 | const int IterationCount = 1000; 14 | 15 | [SetUp] 16 | public void SetUp() 17 | { 18 | Random.InitState((int)DateTime.Now.Ticks); 19 | } 20 | 21 | [Test] 22 | public void Test_Contains_Int_List() 23 | { 24 | for (int i = 0; i < IterationCount; i++) 25 | { 26 | var list = RandomEnumerable.RepeatInt(0, 100, 1000).ToList(); 27 | var value = Random.Range(0, 2) == 0 ? 50 : -1; 28 | 29 | var result1 = Enumerable.Contains(list, value); 30 | var result2 = BurstLinqExtensions.Contains(list, value); 31 | 32 | Assert.AreEqual(result1, result2); 33 | } 34 | } 35 | 36 | [Test] 37 | public void Test_Contains_Int_Array() 38 | { 39 | for (int i = 0; i < IterationCount; i++) 40 | { 41 | var array = RandomEnumerable.RepeatInt(0, 100, 100).ToArray(); 42 | var value = Random.Range(0, 2) == 0 ? 50 : -1; 43 | 44 | var result1 = Enumerable.Contains(array, value); 45 | var result2 = BurstLinqExtensions.Contains(array, value); 46 | 47 | Assert.AreEqual(result1, result2); 48 | } 49 | } 50 | 51 | [Test] 52 | public void Test_Contains_Float_Array() 53 | { 54 | for (int i = 0; i < IterationCount; i++) 55 | { 56 | var array = RandomEnumerable.RepeatFloat(0f, 100f, 1000).ToArray(); 57 | var value = Random.Range(0, 2) == 0 ? 50f : -1f; 58 | 59 | var result1 = Enumerable.Contains(array, value); 60 | var result2 = BurstLinqExtensions.Contains(array, value); 61 | 62 | Assert.AreEqual(result1, result2); 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Max.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double" 11 | }; 12 | #> 13 | using System; 14 | using System.Collections.Generic; 15 | 16 | namespace BurstLinq 17 | { 18 | public unsafe static partial class BurstLinqExtensions 19 | { 20 | <# foreach(var type in types) { #> 21 | public static <#=type#> Max(this <#=type#>[] source) 22 | { 23 | Error.ThrowIfNull(source); 24 | Error.ThrowIfEmpty(source.Length); 25 | 26 | fixed (<#=type#>* ptr = source) 27 | { 28 | MaxCore(ptr, source.Length, out var result); 29 | return result; 30 | } 31 | } 32 | 33 | public static <#=type#> Max(this List<<#=type#>> source) 34 | { 35 | Error.ThrowIfNull(source); 36 | Error.ThrowIfEmpty(source.Count); 37 | 38 | var span = SpanHelper.AsSpan(source); 39 | fixed (<#=type#>* ptr = span) 40 | { 41 | MaxCore(ptr, source.Count, out var result); 42 | return result; 43 | } 44 | } 45 | 46 | public static <#=type#> Max(this Memory<<#=type#>> source) 47 | { 48 | return Max((ReadOnlySpan<<#=type#>>)source.Span); 49 | } 50 | 51 | public static <#=type#> Max(this ReadOnlyMemory<<#=type#>> source) 52 | { 53 | return Max(source.Span); 54 | } 55 | 56 | public static <#=type#> Max(this Span<<#=type#>> source) 57 | { 58 | return Max((ReadOnlySpan<<#=type#>>)source); 59 | } 60 | 61 | public static <#=type#> Max(this ReadOnlySpan<<#=type#>> source) 62 | { 63 | Error.ThrowIfEmpty(source.IsEmpty); 64 | fixed (<#=type#>* ptr = source) 65 | { 66 | MaxCore(ptr, source.Length, out var result); 67 | return result; 68 | } 69 | } 70 | <# } #> 71 | } 72 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Min.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double" 11 | }; 12 | #> 13 | using System; 14 | using System.Collections.Generic; 15 | 16 | namespace BurstLinq 17 | { 18 | public unsafe static partial class BurstLinqExtensions 19 | { 20 | <# foreach(var type in types) { #> 21 | public static <#=type#> Min(this <#=type#>[] source) 22 | { 23 | Error.ThrowIfNull(source); 24 | Error.ThrowIfEmpty(source.Length); 25 | 26 | fixed (<#=type#>* ptr = source) 27 | { 28 | MinCore(ptr, source.Length, out var result); 29 | return result; 30 | } 31 | } 32 | 33 | public static <#=type#> Min(this List<<#=type#>> source) 34 | { 35 | Error.ThrowIfNull(source); 36 | Error.ThrowIfEmpty(source.Count); 37 | 38 | var span = SpanHelper.AsSpan(source); 39 | fixed (<#=type#>* ptr = span) 40 | { 41 | MinCore(ptr, source.Count, out var result); 42 | return result; 43 | } 44 | } 45 | 46 | public static <#=type#> Min(this Memory<<#=type#>> source) 47 | { 48 | return Min((ReadOnlySpan<<#=type#>>)source.Span); 49 | } 50 | 51 | public static <#=type#> Min(this ReadOnlyMemory<<#=type#>> source) 52 | { 53 | return Min(source.Span); 54 | } 55 | 56 | public static <#=type#> Min(this Span<<#=type#>> source) 57 | { 58 | return Min((ReadOnlySpan<<#=type#>>)source); 59 | } 60 | 61 | public static <#=type#> Min(this ReadOnlySpan<<#=type#>> source) 62 | { 63 | Error.ThrowIfEmpty(source.IsEmpty); 64 | fixed (<#=type#>* ptr = source) 65 | { 66 | MinCore(ptr, source.Length, out var result); 67 | return result; 68 | } 69 | } 70 | <# } #> 71 | } 72 | } -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Sum.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "int", "uint", "long", "ulong", "float", "double", 11 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 12 | "int2", "int3", "int4", 13 | "uint2", "uint3", "uint4", 14 | "float2", "float3", "float4", 15 | "double2", "double3", "double4", 16 | }; 17 | #> 18 | using System; 19 | using System.Collections.Generic; 20 | using Unity.Mathematics; 21 | using UnityEngine; 22 | 23 | namespace BurstLinq 24 | { 25 | public unsafe static partial class BurstLinqExtensions 26 | { 27 | <# foreach(var type in types) { #> 28 | public static <#=type#> Sum(this <#=type#>[] source) 29 | { 30 | Error.ThrowIfNull(source); 31 | Error.ThrowIfEmpty(source.Length); 32 | fixed (<#=type#>* ptr = source) 33 | { 34 | SumCore(ptr, source.Length, out var result); 35 | return result; 36 | } 37 | } 38 | 39 | public static <#=type#> Sum(this List<<#=type#>> source) 40 | { 41 | Error.ThrowIfNull(source); 42 | Error.ThrowIfEmpty(source.Count); 43 | 44 | var span = SpanHelper.AsSpan(source); 45 | fixed (<#=type#>* ptr = span) 46 | { 47 | SumCore(ptr, source.Count, out var result); 48 | return result; 49 | } 50 | } 51 | 52 | public static <#=type#> Sum(this Memory<<#=type#>> source) 53 | { 54 | return Sum((ReadOnlySpan<<#=type#>>)source.Span); 55 | } 56 | 57 | public static <#=type#> Sum(this ReadOnlyMemory<<#=type#>> source) 58 | { 59 | return Sum(source.Span); 60 | } 61 | 62 | public static <#=type#> Sum(this Span<<#=type#>> source) 63 | { 64 | return Sum((ReadOnlySpan<<#=type#>>)source); 65 | } 66 | 67 | public static <#=type#> Sum(this ReadOnlySpan<<#=type#>> source) 68 | { 69 | Error.ThrowIfEmpty(source.IsEmpty); 70 | fixed (<#=type#>* ptr = source) 71 | { 72 | SumCore(ptr, source.Length, out var result); 73 | return result; 74 | } 75 | } 76 | <# } #> 77 | } 78 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/SequenceEqualTest.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | string GetTypeName(string typeName) 9 | { 10 | if (typeName[0] == 'u') return "U" + char.ToUpper(typeName[1]) + typeName.Substring(2); 11 | if (typeName == "sbyte") return "SByte"; 12 | return char.ToUpper(typeName[0]) + typeName.Substring(1); 13 | } 14 | 15 | var types = new string[] 16 | { 17 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", 18 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 19 | "int2", "int3", "int4", 20 | "uint2", "uint3", "uint4", 21 | "float2", "float3", "float4", 22 | "double2", "double3", "double4", 23 | }; 24 | #> 25 | using System; 26 | using System.Linq; 27 | using NUnit.Framework; 28 | using Assert = UnityEngine.Assertions.Assert; 29 | using Random = UnityEngine.Random; 30 | 31 | namespace BurstLinq.Tests 32 | { 33 | public class SequenceEqualTest 34 | { 35 | [SetUp] 36 | public void SetUp() 37 | { 38 | Random.InitState((int)DateTime.Now.Ticks); 39 | } 40 | 41 | [Test] 42 | public void Test_List() 43 | { 44 | for (int i = 0; i < 100; i++) 45 | { 46 | var list1 = RandomEnumerable.RepeatInt(0, 2, 10).ToList(); 47 | var list2 = RandomEnumerable.RepeatInt(0, 2, 10).ToList(); 48 | 49 | var result1 = Enumerable.SequenceEqual(list1, list2); 50 | var result2 = BurstLinqExtensions.SequenceEqual(list1, list2); 51 | 52 | Assert.AreEqual(result1, result2); 53 | } 54 | } 55 | 56 | <# foreach(var type in types) { #> 57 | [Test] 58 | public void Test_Array_<#=GetTypeName(type)#>() 59 | { 60 | for (int i = 0; i < 1000; i++) 61 | { 62 | var array1 = RandomEnumerable.Repeat<#=GetTypeName(type)#>(0, 2, 10).ToArray(); 63 | var array2 = RandomEnumerable.Repeat<#=GetTypeName(type)#>(0, 2, 10).ToArray(); 64 | 65 | var result1 = Enumerable.SequenceEqual(array1, array2); 66 | var result2 = BurstLinqExtensions.SequenceEqual(array1, array2); 67 | 68 | Assert.AreEqual(result1, result2); 69 | } 70 | } 71 | 72 | <# } #> 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Contains.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", 11 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 12 | "int2", "int3", "int4", 13 | "uint2", "uint3", "uint4", 14 | "float2", "float3", "float4", 15 | "double2", "double3", "double4", 16 | }; 17 | #> 18 | using System; 19 | using System.Collections.Generic; 20 | using Unity.Mathematics; 21 | using UnityEngine; 22 | 23 | namespace BurstLinq 24 | { 25 | public unsafe static partial class BurstLinqExtensions 26 | { 27 | <# foreach(var type in types) { #> 28 | public static bool Contains(this <#=type#>[] source, <#=type#> value) 29 | { 30 | Error.ThrowIfNull(source); 31 | if (source.Length == 0) return false; 32 | 33 | fixed (<#=type#>* ptr = source) 34 | { 35 | return ContainsCore(ptr, source.Length, value); 36 | } 37 | } 38 | 39 | public static bool Contains(this List<<#=type#>> source, <#=type#> value) 40 | { 41 | Error.ThrowIfNull(source); 42 | if (source.Count == 0) return false; 43 | 44 | var span = SpanHelper.AsSpan(source); 45 | fixed (<#=type#>* ptr = span) 46 | { 47 | return ContainsCore(ptr, source.Count, value); 48 | } 49 | } 50 | 51 | public static bool Contains(this Memory<<#=type#>> source, <#=type#> value) 52 | { 53 | return Contains((ReadOnlySpan<<#=type#>>)source.Span, value); 54 | } 55 | 56 | public static bool Contains(this ReadOnlyMemory<<#=type#>> source, <#=type#> value) 57 | { 58 | return Contains(source.Span, value); 59 | } 60 | 61 | public static bool Contains(this Span<<#=type#>> source, <#=type#> value) 62 | { 63 | return Contains((ReadOnlySpan<<#=type#>>)source, value); 64 | } 65 | 66 | public static bool Contains(this ReadOnlySpan<<#=type#>> source, <#=type#> value) 67 | { 68 | if (source.IsEmpty) return false; 69 | 70 | fixed (<#=type#>* ptr = source) 71 | { 72 | return ContainsCore(ptr, source.Length, value); 73 | } 74 | } 75 | <# } #> 76 | } 77 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Average.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "int", "uint", "long", "ulong", "float", "double", 11 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 12 | "int2", "int3", "int4", 13 | "float2", "float3", "float4", 14 | "double2", "double3", "double4", 15 | }; 16 | 17 | System.Func retType = (string x) => 18 | { 19 | switch (x) 20 | { 21 | default: return "double"; 22 | case "float": return "float"; 23 | case "Vector2": 24 | case "Vector2Int": return "Vector2"; 25 | case "Vector3": 26 | case "Vector3Int": return "Vector3"; 27 | case "Vector4": return "Vector4"; 28 | case "float2": return "float2"; 29 | case "float3": return "float3"; 30 | case "float4": return "float4"; 31 | case "int2": 32 | case "double2": return "double2"; 33 | case "int3": 34 | case "double3": return "double3"; 35 | case "int4": 36 | case "double4": return "double4"; 37 | } 38 | return ""; 39 | }; 40 | #> 41 | using Unity.Burst; 42 | using Unity.Burst.CompilerServices; 43 | using Unity.Collections; 44 | using Unity.Collections.LowLevel.Unsafe; 45 | using Unity.Mathematics; 46 | using UnityEngine; 47 | 48 | namespace BurstLinq 49 | { 50 | public unsafe static partial class BurstLinqExtensions 51 | { 52 | <# foreach(var type in types) { #> 53 | public static <#=retType(type)#> Average(this NativeList<<#=type#>> source) 54 | { 55 | Error.ThrowIfEmpty(source.Length); 56 | AverageCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 57 | return result; 58 | } 59 | 60 | public static <#=retType(type)#> Average(this NativeSlice<<#=type#>> source) 61 | { 62 | Error.ThrowIfEmpty(source.Length); 63 | AverageCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 64 | return result; 65 | } 66 | 67 | public static <#=retType(type)#> Average(this NativeArray<<#=type#>> source) 68 | { 69 | Error.ThrowIfEmpty(source.Length); 70 | AverageCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 71 | return result; 72 | } 73 | 74 | [BurstCompile] 75 | internal static void AverageCore(<#=type#>* ptr, [AssumeRange(1, int.MaxValue)] int length, out <#=retType(type)#> result) 76 | { 77 | SumCore(ptr, length, out var sum); 78 | result = (<#=retType(type)#>)sum / length; 79 | } 80 | 81 | <# } #> 82 | } 83 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/AssertEx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | using UnityEngine.Assertions; 5 | 6 | namespace BurstLinq.Tests 7 | { 8 | public static class AssertEx 9 | { 10 | public static void AreApproximatelyEqual(float a, float b) 11 | { 12 | Assert.AreApproximatelyEqual(a, b, 0.1f); 13 | } 14 | 15 | public static void AreApproximatelyEqual(Vector2 a, Vector2 b) 16 | { 17 | Assert.AreApproximatelyEqual(a.x, b.x, 0.1f); 18 | Assert.AreApproximatelyEqual(a.y, b.y, 0.1f); 19 | } 20 | 21 | public static void AreApproximatelyEqual(Vector3 a, Vector3 b) 22 | { 23 | Assert.AreApproximatelyEqual(a.x, b.x, 0.1f); 24 | Assert.AreApproximatelyEqual(a.y, b.y, 0.1f); 25 | Assert.AreApproximatelyEqual(a.z, b.z, 0.1f); 26 | } 27 | 28 | public static void AreApproximatelyEqual(Vector4 a, Vector4 b) 29 | { 30 | Assert.AreApproximatelyEqual(a.x, b.x, 0.1f); 31 | Assert.AreApproximatelyEqual(a.y, b.y, 0.1f); 32 | Assert.AreApproximatelyEqual(a.z, b.z, 0.1f); 33 | Assert.AreApproximatelyEqual(a.w, b.w, 0.1f); 34 | } 35 | 36 | public static void AreApproximatelyEqual(double a, double b) 37 | { 38 | Assert.IsTrue(Math.Abs(a - b) < 0.001); 39 | } 40 | 41 | public static void AreApproximatelyEqual(double2 a, double2 b) 42 | { 43 | AreApproximatelyEqual(a.x, b.x); 44 | AreApproximatelyEqual(a.y, b.y); 45 | } 46 | 47 | public static void AreApproximatelyEqual(double3 a, double3 b) 48 | { 49 | AreApproximatelyEqual(a.x, b.x); 50 | AreApproximatelyEqual(a.y, b.y); 51 | AreApproximatelyEqual(a.z, b.z); 52 | } 53 | 54 | public static void AreApproximatelyEqual(double4 a, double4 b) 55 | { 56 | AreApproximatelyEqual(a.x, b.x); 57 | AreApproximatelyEqual(a.y, b.y); 58 | AreApproximatelyEqual(a.z, b.z); 59 | AreApproximatelyEqual(a.w, b.w); 60 | } 61 | 62 | public static void AreApproximatelyEqual(float2 a, float2 b) 63 | { 64 | Assert.AreApproximatelyEqual(a.x, b.x, 0.1f); 65 | Assert.AreApproximatelyEqual(a.y, b.y, 0.1f); 66 | } 67 | 68 | public static void AreApproximatelyEqual(float3 a, float3 b) 69 | { 70 | Assert.AreApproximatelyEqual(a.x, b.x, 0.1f); 71 | Assert.AreApproximatelyEqual(a.y, b.y, 0.1f); 72 | Assert.AreApproximatelyEqual(a.z, b.z, 0.1f); 73 | } 74 | 75 | public static void AreApproximatelyEqual(float4 a, float4 b) 76 | { 77 | Assert.AreApproximatelyEqual(a.x, b.x, 0.1f); 78 | Assert.AreApproximatelyEqual(a.y, b.y, 0.1f); 79 | Assert.AreApproximatelyEqual(a.z, b.z, 0.1f); 80 | Assert.AreApproximatelyEqual(a.w, b.w, 0.1f); 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.SequenceEqual.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", 11 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 12 | "int2", "int3", "int4", 13 | "uint2", "uint3", "uint4", 14 | "float2", "float3", "float4", 15 | "double2", "double3", "double4", 16 | }; 17 | 18 | bool IsFloats(string type) 19 | { 20 | return type is "float" or "float2" or "float3" or "float4" or "Vector2" or "Vector3" or "Vector4"; 21 | } 22 | bool IsDoubles(string type) 23 | { 24 | return type is "double" or "double2" or "double3" or "double4" ; 25 | } 26 | #> 27 | 28 | using System.Runtime.CompilerServices; 29 | using Unity.Burst; 30 | using Unity.Burst.CompilerServices; 31 | using Unity.Burst.Intrinsics; 32 | using Unity.Collections; 33 | using Unity.Collections.LowLevel.Unsafe; 34 | using Unity.Mathematics; 35 | using UnityEngine; 36 | 37 | namespace BurstLinq 38 | { 39 | public unsafe static partial class BurstLinqExtensions 40 | { 41 | <# foreach(var type in types) { #> 42 | public static bool SequenceEqual(this NativeList<<#=type#>> first, NativeList<<#=type#>> second) 43 | { 44 | if (first.Length != second.Length) return false; 45 | return SequenceEqualCore((<#=type#>*)first.GetUnsafePtr(), (<#=type#>*)second.GetUnsafePtr(), first.Length); 46 | } 47 | 48 | public static bool SequenceEqual(this NativeSlice<<#=type#>> first, NativeSlice<<#=type#>> second) 49 | { 50 | if (first.Length != second.Length) return false; 51 | return SequenceEqualCore((<#=type#>*)first.GetUnsafePtr(), (<#=type#>*)second.GetUnsafePtr(), first.Length); 52 | } 53 | 54 | public static bool SequenceEqual(this NativeArray<<#=type#>> first, NativeArray<<#=type#>> second) 55 | { 56 | if (first.Length != second.Length) return false; 57 | return SequenceEqualCore((<#=type#>*)first.GetUnsafePtr(), (<#=type#>*)second.GetUnsafePtr(), first.Length); 58 | } 59 | 60 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 61 | internal static bool SequenceEqualCore(<#=type#>* firstPtr, <#=type#>* secondPtr, [AssumeRange(0, int.MaxValue)] int length) 62 | { 63 | <# if (IsFloats(type)){#> 64 | return CmpHelpers.FloatCmp((float*)firstPtr, (float*)secondPtr, length*(sizeof(<#=type#>) / sizeof(float))); 65 | <# } else if(IsDoubles(type)){#> 66 | return CmpHelpers.DoubleCmp((double*)firstPtr, (double*)secondPtr, length*(sizeof(<#=type#>) / sizeof(double))); 67 | <# } else{#> 68 | return CmpHelpers.MemCmp(firstPtr, secondPtr, length * (sizeof(<#=type#>))); 69 | <# } #> 70 | } 71 | 72 | <# } #> 73 | } 74 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/SumTest.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | string GetTypeName(string typeName) 9 | { 10 | if (typeName[0] == 'u') return "U" + char.ToUpper(typeName[1]) + typeName.Substring(2); 11 | if (typeName == "sbyte") return "SByte"; 12 | return char.ToUpper(typeName[0]) + typeName.Substring(1); 13 | } 14 | 15 | bool IsLinqSupport(string typeName) 16 | { 17 | return typeName is "int" or "long" or "float" or "double"; 18 | } 19 | 20 | bool IsFloat(string typeName) 21 | { 22 | return typeName is "float" or "float2" or "float3" or "float4" 23 | or "double" or "double2" or "double3" or "double4" 24 | or "Vector2" or "Vector3" or "Vector4"; 25 | } 26 | 27 | var types = new string[] 28 | { 29 | "int", "uint", "long", "ulong", "float", "double", 30 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 31 | "int2", "int3", "int4", 32 | "uint2", "uint3", "uint4", 33 | "float2", "float3", "float4", 34 | "double2", "double3", "double4", 35 | }; 36 | #> 37 | using System; 38 | using System.Linq; 39 | using NUnit.Framework; 40 | using Unity.Mathematics; 41 | using UnityEngine; 42 | using Assert = UnityEngine.Assertions.Assert; 43 | using Random = UnityEngine.Random; 44 | 45 | namespace BurstLinq.Tests 46 | { 47 | public class SumTest 48 | { 49 | [SetUp] 50 | public void SetUp() 51 | { 52 | Random.InitState((int)DateTime.Now.Ticks); 53 | } 54 | 55 | [Test] 56 | public void Test_List() 57 | { 58 | for (int i = 0; i < 1000; i++) 59 | { 60 | var list = RandomEnumerable.RepeatInt(0, 100, 1000).ToList(); 61 | 62 | var result1 = Enumerable.Sum(list); 63 | var result2 = BurstLinqExtensions.Sum(list); 64 | 65 | Assert.AreEqual(result1, result2); 66 | } 67 | } 68 | 69 | <# foreach(var type in types) { #> 70 | [Test] 71 | public void Test_Array_<#=GetTypeName(type)#>() 72 | { 73 | for (int i = 0; i < 1000; i++) 74 | { 75 | var array = RandomEnumerable.Repeat<#=GetTypeName(type)#>(0, 100, 1000).ToArray(); 76 | 77 | <# if (IsLinqSupport(type)) { #> 78 | var result1 = Enumerable.Sum(array); 79 | var result2 = BurstLinqExtensions.Sum(array); 80 | <# } else { #> 81 | <#=type#> result1 = default; 82 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 83 | var result2 = BurstLinqExtensions.Sum(array); 84 | <# } #> 85 | 86 | <# if (IsFloat(type)) { #> 87 | AssertEx.AreApproximatelyEqual(result1, result2); 88 | <# } else { #> 89 | Assert.AreEqual(result1, result2); 90 | <# } #> 91 | } 92 | } 93 | 94 | <# } #> 95 | } 96 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Sum.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "int", "uint", "long", "ulong", "float", "double", 11 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 12 | "int2", "int3", "int4", 13 | "uint2", "uint3", "uint4", 14 | "float2", "float3", "float4", 15 | "double2", "double3", "double4", 16 | }; 17 | 18 | bool TryGetTwiceVector(string type, out string longer) 19 | { 20 | longer = null; 21 | switch (type) 22 | { 23 | case "int2": longer = "int4"; return true; 24 | case "uint2": longer = "uint4"; return true; 25 | case "float2": longer = "float4"; return true; 26 | case "double2": longer = "double4"; return true; 27 | case "Vector2": longer = "float4"; return true; 28 | case "Vector2Int": longer = "int4"; return true; 29 | default: return false; 30 | } 31 | } 32 | 33 | #> 34 | using Unity.Burst; 35 | using Unity.Burst.CompilerServices; 36 | using Unity.Collections; 37 | using Unity.Collections.LowLevel.Unsafe; 38 | using Unity.Mathematics; 39 | using UnityEngine; 40 | 41 | namespace BurstLinq 42 | { 43 | public unsafe static partial class BurstLinqExtensions 44 | { 45 | <# foreach(var type in types) { #> 46 | public static <#=type#> Sum(this NativeList<<#=type#>> source) 47 | { 48 | Error.ThrowIfEmpty(source.Length); 49 | SumCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 50 | return result; 51 | } 52 | 53 | public static <#=type#> Sum(this NativeSlice<<#=type#>> source) 54 | { 55 | Error.ThrowIfEmpty(source.Length); 56 | SumCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 57 | return result; 58 | } 59 | 60 | public static <#=type#> Sum(this NativeArray<<#=type#>> source) 61 | { 62 | Error.ThrowIfEmpty(source.Length); 63 | SumCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 64 | return result; 65 | } 66 | 67 | <#if (TryGetTwiceVector(type, out var twiceType)) { #> 68 | [BurstCompile(FloatMode = FloatMode.Fast)] 69 | internal static void SumCore(<#=type#>* ptr, [AssumeRange(1, int.MaxValue)] int length, out <#=type#> result) 70 | { 71 | SumCore((<#=twiceType#>*)ptr, length / 2, out var sum2); 72 | var sum = new <#=type#>(sum2.x + sum2.z, sum2.y + sum2.w); 73 | if (length % 2 == 1) sum += ptr[length - 1]; 74 | result = sum; 75 | } 76 | <# } else { #> 77 | [BurstCompile(FloatMode = FloatMode.Fast)] 78 | internal static void SumCore(<#=type#>* ptr, [AssumeRange(1, int.MaxValue)] int length, out <#=type#> result) 79 | { 80 | var sum = default(<#=type#>); 81 | for (int i = 0; i < length; i++) sum += ptr[i]; 82 | result = sum; 83 | } 84 | <# } #> 85 | 86 | <# } #> 87 | } 88 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/CmpHelpers.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Burst.CompilerServices; 3 | using Unity.Burst.Intrinsics; 4 | using Unity.Collections.LowLevel.Unsafe; 5 | using Unity.Mathematics; 6 | 7 | namespace BurstLinq 8 | { 9 | [BurstCompile] 10 | internal static unsafe class CmpHelpers 11 | { 12 | [BurstCompile] 13 | public static bool MemCmp(void* ptr1, void* ptr2, long size) 14 | { 15 | return UnsafeUtility.MemCmp(ptr1, ptr2, size) == 0; 16 | } 17 | 18 | [BurstCompile] 19 | public static bool FloatCmp(float* ptr1, float* ptr2, [AssumeRange(1, long.MaxValue)] long length) 20 | { 21 | long index = 0; 22 | if (BurstHelpers.IsV256Supported) 23 | { 24 | static bool8 _equals256(v256 a, v256 b) 25 | { 26 | return new bool8( 27 | a.Float0 == b.Float0, 28 | a.Float1 == b.Float1, 29 | a.Float2 == b.Float2, 30 | a.Float3 == b.Float3, 31 | a.Float4 == b.Float4, 32 | a.Float5 == b.Float5, 33 | a.Float6 == b.Float6, 34 | a.Float7 == b.Float7 35 | ); 36 | } 37 | 38 | var packingLength = sizeof(v256) / sizeof(float); 39 | 40 | for (; index < length - packingLength; index += packingLength) 41 | { 42 | if (!_equals256(*(v256*)(ptr1 + index), *(v256*)(ptr2 + index)).all()) 43 | return false; 44 | } 45 | } 46 | else if (BurstHelpers.IsV128Supported) 47 | { 48 | var packingLength = sizeof(v128) / sizeof(float); 49 | 50 | for (; index < length - packingLength; index += packingLength) 51 | { 52 | if (math.any(*(float4*)(ptr1 + index) != *(float4*)(ptr2 + index))) return false; 53 | } 54 | } 55 | 56 | for (; index < length; index++) 57 | { 58 | if (ptr1[index] != ptr2[index]) return false; 59 | } 60 | 61 | return true; 62 | } 63 | 64 | [BurstCompile] 65 | public static bool DoubleCmp(double* ptr1, double* ptr2, [AssumeRange(1, long.MaxValue)] long length) 66 | { 67 | long index = 0; 68 | if (BurstHelpers.IsV256Supported) 69 | { 70 | var packingLength = sizeof(v256) / sizeof(double); 71 | 72 | for (; index < length - packingLength; index += packingLength) 73 | { 74 | if (math.any(*(double4*)(ptr1 + index) != *(double4*)(ptr2 + index))) return false; 75 | } 76 | } 77 | else if (BurstHelpers.IsV128Supported) 78 | { 79 | var packingLength = sizeof(v128) / sizeof(double); 80 | 81 | for (; index < length - packingLength; index += packingLength) 82 | { 83 | if (math.any(*(double2*)(ptr1 + index) != *(double2*)(ptr2 + index))) return false; 84 | } 85 | } 86 | 87 | for (; index < length; index++) 88 | { 89 | if (ptr1[index] != ptr2[index]) return false; 90 | } 91 | return true; 92 | } 93 | 94 | } 95 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Average.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "int", "uint", "long", "ulong", "float", "double", 11 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 12 | "int2", "int3", "int4", 13 | "float2", "float3", "float4", 14 | "double2", "double3", "double4", 15 | }; 16 | 17 | System.Func retType = (string x) => 18 | { 19 | switch (x) 20 | { 21 | default: return "double"; 22 | case "float": return "float"; 23 | case "Vector2": 24 | case "Vector2Int": return "Vector2"; 25 | case "Vector3": 26 | case "Vector3Int": return "Vector3"; 27 | case "Vector4": return "Vector4"; 28 | case "float2": return "float2"; 29 | case "float3": return "float3"; 30 | case "float4": return "float4"; 31 | case "int2": 32 | case "double2": return "double2"; 33 | case "int3": 34 | case "double3": return "double3"; 35 | case "int4": 36 | case "double4": return "double4"; 37 | } 38 | return ""; 39 | }; 40 | #> 41 | using System; 42 | using System.Collections.Generic; 43 | using Unity.Collections; 44 | using Unity.Mathematics; 45 | using UnityEngine; 46 | 47 | namespace BurstLinq 48 | { 49 | public unsafe static partial class BurstLinqExtensions 50 | { 51 | <# foreach(var type in types) { #> 52 | public static <#=retType(type)#> Average(this <#=type#>[] source) 53 | { 54 | Error.ThrowIfNull(source); 55 | Error.ThrowIfEmpty(source.Length); 56 | 57 | fixed (<#=type#>* ptr = source) 58 | { 59 | AverageCore(ptr, source.Length, out var result); 60 | return result; 61 | } 62 | } 63 | 64 | public static <#=retType(type)#> Average(this List<<#=type#>> source) 65 | { 66 | Error.ThrowIfNull(source); 67 | Error.ThrowIfEmpty(source.Count); 68 | 69 | var span = SpanHelper.AsSpan(source); 70 | fixed (<#=type#>* ptr = span) 71 | { 72 | AverageCore(ptr, source.Count, out var result); 73 | return result; 74 | } 75 | } 76 | 77 | public static <#=retType(type)#> Average(this Memory<<#=type#>> source) 78 | { 79 | return Average((ReadOnlySpan<<#=type#>>)source.Span); 80 | } 81 | 82 | public static <#=retType(type)#> Average(this ReadOnlyMemory<<#=type#>> source) 83 | { 84 | return Average(source.Span); 85 | } 86 | 87 | public static <#=retType(type)#> Average(this Span<<#=type#>> source) 88 | { 89 | return Average((ReadOnlySpan<<#=type#>>)source); 90 | } 91 | 92 | public static <#=retType(type)#> Average(this ReadOnlySpan<<#=type#>> source) 93 | { 94 | Error.ThrowIfEmpty(source.IsEmpty); 95 | 96 | fixed (<#=type#>* ptr = source) 97 | { 98 | AverageCore(ptr, source.Length, out var result); 99 | return result; 100 | } 101 | } 102 | <# } #> 103 | } 104 | } -------------------------------------------------------------------------------- /README_JA.md: -------------------------------------------------------------------------------- 1 | # BurstLinq 2 | Extremely fast LINQ aggregation operations implementation optimized by Burst Compiler 3 | 4 | 5 | 6 | [![license](https://img.shields.io/badge/LICENSE-MIT-green.svg)](LICENSE) 7 | 8 | [English README is here](README.md) 9 | 10 | ## 概要 11 | 12 | BurstLinqはUnityのBurst Compilerを用いてLINQの集約操作(`Sum`、`Average`、`Min`, etc..)を高速化するライブラリです。BurstLinqを導入することで、Burstが適用可能なLINQメソッドに対して自動的に最適化された実装が適用されるようになり、通常のLINQと比較して遥かに高いパフォーマンスを実現します。 13 | 14 | また、`NativeArray`や`Span`など本来LINQが使用できないコレクション型に対して`Sum`、`Min`などのオペレータを追加するほか、`Vector3`、`float3`などのUnity独自の型に対する`Sum`、`Average`もサポートします。 15 | 16 | > BurstLinqのコンセプトは[Cysharp/SimdLinq](https://github.com/Cysharp/SimdLinq)にインスパイアされており、こちらは.NETのSIMD APIの代わりにBurstを利用した、Unityに最適化された実装になっています。 17 | 18 | ## セットアップ 19 | 20 | ### 要件 21 | 22 | * Unity 2021.3 以上 23 | * Burst 1.6.0 以上 24 | 25 | ### インストール 26 | 27 | 1. Window > Package ManagerからPackage Managerを開く 28 | 2. 「+」ボタン > Add package from git URL 29 | 3. 以下のURLを入力する 30 | 31 | ``` 32 | https://github.com/AnnulusGames/BurstLinq.git?path=/Assets/BurstLinq 33 | ``` 34 | 35 | あるいはPackages/manifest.jsonを開き、dependenciesブロックに以下を追記 36 | 37 | ```json 38 | { 39 | "dependencies": { 40 | "com.annulusgames.burst-linq": "https://github.com/AnnulusGames/BurstLinq.git?path=/Assets/BurstLinq" 41 | } 42 | } 43 | ``` 44 | 45 | ## Quick Start 46 | 47 | BurstLinqはSimdLinqと同様'Drop-in replacement'となるように設計されており、`using BurstLinq;`を含めるだけでBurstが適用可能な全てのオペレータに対して自動的にBurstLinqのメソッドを適用します。 48 | 49 | ```cs 50 | using System.Collections.Generic; 51 | using System.Linq; 52 | using BurstLinq; 53 | 54 | var enumerable = Enumerable.Range(0, 100); 55 | var array = enumerable.ToArray(); 56 | 57 | // Enumerable.Sum() 58 | var linqSum = enumerable.Sum(); 59 | 60 | // BurstLinqExtensions.Sum() 61 | var burstLinqSum = array.Sum(); 62 | ``` 63 | 64 | ## サポートする型とオペレータ 65 | 66 | BurstLinqが対応するオペレータと型の一覧は以下の通りです。 67 | 68 | ### サポートするコレクション型 69 | 70 | * `T[]` 71 | * `List` 72 | * `Memory` 73 | * `ReadOnlyMemory` 74 | * `Span` 75 | * `ReadOnlySpan` 76 | * `NativeArray` 77 | * `NativeList` 78 | * `NativeSlice` 79 | 80 | ### サポートするオペレータ 81 | 82 | * Sum (`int`, `uint`, `long`, `ulong`, `float`, `double`, `Vector2`, `Vector3`, `Vector4`, `int2..4`, `uint2..4`, `float2..4`, `double2..4`) 83 | * Average (`int`, `uint`, `long`, `ulong`, `float`, `double`, `Vector2`, `Vector3`, `Vector4`, `int2..4`, `uint2..4`, `float2..4`, `double2..4`) 84 | * Min (`byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`) 85 | * Max (`byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`) 86 | * Contains (`byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, `Vector2`, `Vector3`, `Vector4`, `int2..4`, `uint2..4`, `float2..4`, `double2..4`) 87 | * SequenceEqual (`byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, `Vector2`, `Vector3`, `Vector4`, `int2..4`, `uint2..4`, `float2..4`, `double2..4`) 88 | 89 | ## LINQとの互換性 90 | 91 | BurstLinqはパフォーマンスの高さを優先するため、LINQと比べて挙動が異なる場合があります。使用する際は以下の違いに注意してください。 92 | 93 | ### Sum/Average 94 | 95 | LINQのSumは`checked`ですが、BurstLinqは`unchecked`です。Burstはオーバーフローの検知をサポートしないため、Burstが無効化された際に動作の違いが生じないように`unchecked`としています。 96 | 97 | ### 浮動小数点型の扱い 98 | 99 | BurstLinqのSumは`[BurstCompile(FloatMode = FloatMode.Fast)]`を指定するため、通常のLINQのSumと比較して計算結果に僅かな誤差が生じます。これが問題になることは稀ですが、互換性がないことには留意してください。 100 | 101 | またBurstLinqはfloat/doubleに対するNaNのチェックを行わないため、その点にも注意してください。 102 | 103 | ## ライセンス 104 | 105 | [MIT License](LICENSE) -------------------------------------------------------------------------------- /ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "defaultInstantiationMode": 0 8 | }, 9 | { 10 | "userAdded": false, 11 | "type": "UnityEditor.Animations.AnimatorController", 12 | "defaultInstantiationMode": 0 13 | }, 14 | { 15 | "userAdded": false, 16 | "type": "UnityEngine.AnimatorOverrideController", 17 | "defaultInstantiationMode": 0 18 | }, 19 | { 20 | "userAdded": false, 21 | "type": "UnityEditor.Audio.AudioMixerController", 22 | "defaultInstantiationMode": 0 23 | }, 24 | { 25 | "userAdded": false, 26 | "type": "UnityEngine.ComputeShader", 27 | "defaultInstantiationMode": 1 28 | }, 29 | { 30 | "userAdded": false, 31 | "type": "UnityEngine.Cubemap", 32 | "defaultInstantiationMode": 0 33 | }, 34 | { 35 | "userAdded": false, 36 | "type": "UnityEngine.GameObject", 37 | "defaultInstantiationMode": 0 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEditor.LightingDataAsset", 42 | "defaultInstantiationMode": 0 43 | }, 44 | { 45 | "userAdded": false, 46 | "type": "UnityEngine.LightingSettings", 47 | "defaultInstantiationMode": 0 48 | }, 49 | { 50 | "userAdded": false, 51 | "type": "UnityEngine.Material", 52 | "defaultInstantiationMode": 0 53 | }, 54 | { 55 | "userAdded": false, 56 | "type": "UnityEditor.MonoScript", 57 | "defaultInstantiationMode": 1 58 | }, 59 | { 60 | "userAdded": false, 61 | "type": "UnityEngine.PhysicMaterial", 62 | "defaultInstantiationMode": 0 63 | }, 64 | { 65 | "userAdded": false, 66 | "type": "UnityEngine.PhysicsMaterial2D", 67 | "defaultInstantiationMode": 0 68 | }, 69 | { 70 | "userAdded": false, 71 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 72 | "defaultInstantiationMode": 0 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 77 | "defaultInstantiationMode": 0 78 | }, 79 | { 80 | "userAdded": false, 81 | "type": "UnityEngine.Rendering.VolumeProfile", 82 | "defaultInstantiationMode": 0 83 | }, 84 | { 85 | "userAdded": false, 86 | "type": "UnityEditor.SceneAsset", 87 | "defaultInstantiationMode": 1 88 | }, 89 | { 90 | "userAdded": false, 91 | "type": "UnityEngine.Shader", 92 | "defaultInstantiationMode": 1 93 | }, 94 | { 95 | "userAdded": false, 96 | "type": "UnityEngine.ShaderVariantCollection", 97 | "defaultInstantiationMode": 1 98 | }, 99 | { 100 | "userAdded": false, 101 | "type": "UnityEngine.Texture", 102 | "defaultInstantiationMode": 0 103 | }, 104 | { 105 | "userAdded": false, 106 | "type": "UnityEngine.Texture2D", 107 | "defaultInstantiationMode": 0 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Timeline.TimelineAsset", 112 | "defaultInstantiationMode": 0 113 | } 114 | ], 115 | "defaultDependencyTypeInfo": { 116 | "userAdded": false, 117 | "type": "", 118 | "defaultInstantiationMode": 1 119 | }, 120 | "newSceneOverride": 0 121 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/AverageTest.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | string GetTypeName(string typeName) 9 | { 10 | if (typeName[0] == 'u') return "U" + char.ToUpper(typeName[1]) + typeName.Substring(2); 11 | if (typeName == "sbyte") return "SByte"; 12 | return char.ToUpper(typeName[0]) + typeName.Substring(1); 13 | } 14 | 15 | bool IsLinqSupport(string typeName) 16 | { 17 | return typeName is "int" or "long" or "float" or "double"; 18 | } 19 | 20 | bool IsFloat(string typeName) 21 | { 22 | return typeName is "float" or "float2" or "float3" or "float4" 23 | or "double" or "double2" or "double3" or "double4" 24 | or "Vector2" or "Vector3" or "Vector4"; 25 | } 26 | 27 | var types = new string[] 28 | { 29 | "int", "uint", "long", "ulong", "float", "double", 30 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 31 | "int2", "int3", "int4", 32 | "float2", "float3", "float4", 33 | "double2", "double3", "double4", 34 | }; 35 | 36 | System.Func retType = (string x) => 37 | { 38 | switch (x) 39 | { 40 | default: return "double"; 41 | case "float": return "float"; 42 | case "Vector2": 43 | case "Vector2Int": return "Vector2"; 44 | case "Vector3": 45 | case "Vector3Int": return "Vector3"; 46 | case "Vector4": return "Vector4"; 47 | case "float2": return "float2"; 48 | case "float3": return "float3"; 49 | case "float4": return "float4"; 50 | case "int2": 51 | case "double2": return "double2"; 52 | case "int3": 53 | case "double3": return "double3"; 54 | case "int4": 55 | case "double4": return "double4"; 56 | } 57 | return ""; 58 | }; 59 | #> 60 | using System; 61 | using System.Linq; 62 | using NUnit.Framework; 63 | using UnityEngine; 64 | using Unity.Mathematics; 65 | using Assert = UnityEngine.Assertions.Assert; 66 | using Random = UnityEngine.Random; 67 | 68 | namespace BurstLinq.Tests 69 | { 70 | public class AverageTest 71 | { 72 | [SetUp] 73 | public void SetUp() 74 | { 75 | Random.InitState((int)DateTime.Now.Ticks); 76 | } 77 | 78 | [Test] 79 | public void Test_List() 80 | { 81 | for (int i = 0; i < 100; i++) 82 | { 83 | var list = RandomEnumerable.RepeatInt(0, 100, 1000).ToList(); 84 | 85 | var result1 = Enumerable.Average(list); 86 | var result2 = BurstLinqExtensions.Average(list); 87 | 88 | Assert.AreEqual(result1, result2); 89 | } 90 | } 91 | 92 | <# foreach(var type in types) { #> 93 | [Test] 94 | public void Test_Array_<#=GetTypeName(type)#>() 95 | { 96 | for (int i = 0; i < 1000; i++) 97 | { 98 | var array = RandomEnumerable.Repeat<#=GetTypeName(type)#>(0, 100, 1000).ToArray(); 99 | 100 | <# if (IsLinqSupport(type)) { #> 101 | var result1 = Enumerable.Average(array); 102 | var result2 = BurstLinqExtensions.Average(array); 103 | <# } else { #> 104 | <#=type#> sum = default; 105 | for (int n = 0; n < array.Length; n++) sum += array[n]; 106 | var result1 = (<#=retType(type)#>)sum / array.Length; 107 | var result2 = BurstLinqExtensions.Average(array); 108 | <# } #> 109 | 110 | <# if (IsFloat(retType(type))) { #> 111 | AssertEx.AreApproximatelyEqual(result1, result2); 112 | <# } else { #> 113 | Assert.AreEqual(result1, result2); 114 | <# } #> 115 | } 116 | } 117 | 118 | <# } #> 119 | } 120 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BurstLinq 2 | Extremely fast LINQ aggregation operations implementation optimized by Burst Compiler 3 | 4 | 5 | 6 | [![license](https://img.shields.io/badge/LICENSE-MIT-green.svg)](LICENSE) 7 | 8 | [日本語版READMEはこちら](README_JA.md) 9 | 10 | ## Overview 11 | 12 | BurstLinq is a library designed to accelerate LINQ aggregation operations (`Sum`, `Average`, `Min`, etc.) using Unity's Burst Compiler. By integrating BurstLinq, automatically optimized implementations are applied to LINQ methods eligible for Burst, resulting in significantly higher performance compared to regular LINQ. 13 | 14 | Additionally, BurstLinq adds operators like `Sum`, `Min`, etc., to collection types that LINQ cannot usually operate on, such as `NativeArray` or `Span`. It also supports operations like `Sum` and `Average` for Unity-specific types such as `Vector3` and `float3`. 15 | 16 | > The concept of BurstLinq is inspired by [Cysharp/SimdLinq](https://github.com/Cysharp/SimdLinq). BurstLinq is a Unity-optimized version that uses Burst instead of .NET's SIMD API. 17 | 18 | ## Setup 19 | 20 | ### Requirements 21 | 22 | * Unity 2021.3 or later 23 | * Burst 1.6.0 or later 24 | 25 | ### Installation 26 | 27 | 1. Open the Package Manager by going to Window > Package Manager. 28 | 2. Click on the "+" button and select "Add package from git URL". 29 | 3. Enter the following URL: 30 | 31 | ``` 32 | https://github.com/AnnulusGames/BurstLinq.git?path=/Assets/BurstLinq 33 | ``` 34 | 35 | Alternatively, open `Packages/manifest.json` and add the following to the `dependencies` block: 36 | 37 | ```json 38 | { 39 | "dependencies": { 40 | "com.annulusgames.burst-linq": "https://github.com/AnnulusGames/BurstLinq.git?path=/Assets/BurstLinq" 41 | } 42 | } 43 | ``` 44 | 45 | ## Quick Start 46 | 47 | BurstLinq is designed as a 'Drop-in replacement' similar to SimdLinq, simply including `using BurstLinq;` will automatically apply BurstLinq methods to all operators eligible for Burst. 48 | 49 | ```cs 50 | using System.Collections.Generic; 51 | using System.Linq; 52 | using BurstLinq; 53 | 54 | var enumerable = Enumerable.Range(0, 100); 55 | var array = enumerable.ToArray(); 56 | 57 | // Enumerable.Sum() 58 | var linqSum = enumerable.Sum(); 59 | 60 | // BurstLinqExtensions.Sum() 61 | var burstLinqSum = array.Sum(); 62 | ``` 63 | 64 | ## Supported Types and Operators 65 | 66 | Below is the list of operators and types supported by BurstLinq. 67 | 68 | ### Supported Collection Types 69 | 70 | * `T[]` 71 | * `List` 72 | * `Memory` 73 | * `ReadOnlyMemory` 74 | * `Span` 75 | * `ReadOnlySpan` 76 | * `NativeArray` 77 | * `NativeList` 78 | * `NativeSlice` 79 | 80 | ### Supported Operators 81 | 82 | * Sum (`int`, `uint`, `long`, `ulong`, `float`, `double`, `Vector2`, `Vector3`, `Vector4`, `int2..4`, `uint2..4`, `float2..4`, `double2..4`) 83 | * Average (`int`, `uint`, `long`, `ulong`, `float`, `double`, `Vector2`, `Vector3`, `Vector4`, `int2..4`, `uint2..4`, `float2..4`, `double2..4`) 84 | * Min (`byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`) 85 | * Max (`byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`) 86 | * Contains (`byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, `Vector2`, `Vector3`, `Vector4`, `int2..4`, `uint2..4`, `float2..4`, `double2..4`) 87 | * SequenceEqual (`byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, `Vector2`, `Vector3`, `Vector4`, `int2..4`, `uint2..4`, `float2..4`, `double2..4`) 88 | 89 | ## Compatibility with LINQ 90 | 91 | BurstLinq may behave differently compared to LINQ as it prioritizes high performance. Be mindful of the following differences when using it. 92 | 93 | ### Sum/Average 94 | 95 | While LINQ's Sum is `checked`, BurstLinq is `unchecked`. Burst does not support overflow detection, hence it is set to `unchecked` to avoid behavioral differences when Burst is disabled. 96 | 97 | ### Handling of Floating-Point Types 98 | 99 | BurstLinq's `Sum` specifies `[BurstCompile(FloatMode = FloatMode.Fast)]`, resulting in slight computational discrepancies compared to regular LINQ's `Sum`. While this is rarely an issue, note the lack of compatibility. 100 | 101 | Additionally, BurstLinq does not check for NaN for float/double types, so please take note of this aspect. 102 | 103 | ## License 104 | 105 | [MIT License](LICENSE) -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/MaxTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using NUnit.Framework; 4 | using Assert = UnityEngine.Assertions.Assert; 5 | using Random = UnityEngine.Random; 6 | 7 | namespace BurstLinq.Tests 8 | { 9 | public class MaxTest 10 | { 11 | [SetUp] 12 | public void SetUp() 13 | { 14 | Random.InitState((int)DateTime.Now.Ticks); 15 | } 16 | 17 | [Test] 18 | public void Test_List() 19 | { 20 | for (int i = 0; i < 1000; i++) 21 | { 22 | var list = RandomEnumerable.RepeatInt(0, 100, 1000).ToList(); 23 | 24 | var result1 = Enumerable.Max(list); 25 | var result2 = BurstLinqExtensions.Max(list); 26 | 27 | Assert.AreEqual(result1, result2); 28 | } 29 | } 30 | 31 | [Test] 32 | public void Test_Array_Byte() 33 | { 34 | for (int i = 0; i < 1000; i++) 35 | { 36 | var array = RandomEnumerable.RepeatByte(0, 100, 1000).ToArray(); 37 | 38 | var result1 = Enumerable.Max(array); 39 | var result2 = BurstLinqExtensions.Max(array); 40 | 41 | Assert.AreEqual(result1, result2); 42 | } 43 | } 44 | 45 | [Test] 46 | public void Test_Array_SByte() 47 | { 48 | for (int i = 0; i < 1000; i++) 49 | { 50 | var array = RandomEnumerable.RepeatSByte(0, 100, 1000).ToArray(); 51 | 52 | var result1 = Enumerable.Max(array); 53 | var result2 = BurstLinqExtensions.Max(array); 54 | 55 | Assert.AreEqual(result1, result2); 56 | } 57 | } 58 | 59 | [Test] 60 | public void Test_Array_Short() 61 | { 62 | for (int i = 0; i < 1000; i++) 63 | { 64 | var array = RandomEnumerable.RepeatShort(0, 100, 1000).ToArray(); 65 | 66 | var result1 = Enumerable.Max(array); 67 | var result2 = BurstLinqExtensions.Max(array); 68 | 69 | Assert.AreEqual(result1, result2); 70 | } 71 | } 72 | 73 | [Test] 74 | public void Test_Array_UShort() 75 | { 76 | for (int i = 0; i < 1000; i++) 77 | { 78 | var array = RandomEnumerable.RepeatUShort(0, 100, 1000).ToArray(); 79 | 80 | var result1 = Enumerable.Max(array); 81 | var result2 = BurstLinqExtensions.Max(array); 82 | 83 | Assert.AreEqual(result1, result2); 84 | } 85 | } 86 | 87 | [Test] 88 | public void Test_Array_Int() 89 | { 90 | for (int i = 0; i < 1000; i++) 91 | { 92 | var array = RandomEnumerable.RepeatInt(0, 100, 1000).ToArray(); 93 | 94 | var result1 = Enumerable.Max(array); 95 | var result2 = BurstLinqExtensions.Max(array); 96 | 97 | Assert.AreEqual(result1, result2); 98 | } 99 | } 100 | 101 | [Test] 102 | public void Test_Array_UInt() 103 | { 104 | for (int i = 0; i < 1000; i++) 105 | { 106 | var array = RandomEnumerable.RepeatUInt(0, 100, 1000).ToArray(); 107 | 108 | var result1 = Enumerable.Max(array); 109 | var result2 = BurstLinqExtensions.Max(array); 110 | 111 | Assert.AreEqual(result1, result2); 112 | } 113 | } 114 | 115 | [Test] 116 | public void Test_Array_Long() 117 | { 118 | for (int i = 0; i < 1000; i++) 119 | { 120 | var array = RandomEnumerable.RepeatLong(0, 100, 1000).ToArray(); 121 | 122 | var result1 = Enumerable.Max(array); 123 | var result2 = BurstLinqExtensions.Max(array); 124 | 125 | Assert.AreEqual(result1, result2); 126 | } 127 | } 128 | 129 | [Test] 130 | public void Test_Array_ULong() 131 | { 132 | for (int i = 0; i < 1000; i++) 133 | { 134 | var array = RandomEnumerable.RepeatULong(0, 100, 1000).ToArray(); 135 | 136 | var result1 = Enumerable.Max(array); 137 | var result2 = BurstLinqExtensions.Max(array); 138 | 139 | Assert.AreEqual(result1, result2); 140 | } 141 | } 142 | 143 | [Test] 144 | public void Test_Array_Float() 145 | { 146 | for (int i = 0; i < 1000; i++) 147 | { 148 | var array = RandomEnumerable.RepeatFloat(0, 100, 1000).ToArray(); 149 | 150 | var result1 = Enumerable.Max(array); 151 | var result2 = BurstLinqExtensions.Max(array); 152 | 153 | Assert.AreEqual(result1, result2); 154 | } 155 | } 156 | 157 | [Test] 158 | public void Test_Array_Double() 159 | { 160 | for (int i = 0; i < 1000; i++) 161 | { 162 | var array = RandomEnumerable.RepeatDouble(0, 100, 1000).ToArray(); 163 | 164 | var result1 = Enumerable.Max(array); 165 | var result2 = BurstLinqExtensions.Max(array); 166 | 167 | Assert.AreEqual(result1, result2); 168 | } 169 | } 170 | 171 | } 172 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/MinTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using NUnit.Framework; 4 | using Assert = UnityEngine.Assertions.Assert; 5 | using Random = UnityEngine.Random; 6 | 7 | namespace BurstLinq.Tests 8 | { 9 | public class MinTest 10 | { 11 | [SetUp] 12 | public void SetUp() 13 | { 14 | Random.InitState((int)DateTime.Now.Ticks); 15 | } 16 | 17 | [Test] 18 | public void Test_List() 19 | { 20 | for (int i = 0; i < 1000; i++) 21 | { 22 | var list = RandomEnumerable.RepeatInt(0, 100, 1000).ToList(); 23 | 24 | var result1 = Enumerable.Min(list); 25 | var result2 = BurstLinqExtensions.Min(list); 26 | 27 | Assert.AreEqual(result1, result2); 28 | } 29 | } 30 | 31 | [Test] 32 | public void Test_Array_Byte() 33 | { 34 | for (int i = 0; i < 1000; i++) 35 | { 36 | var array = RandomEnumerable.RepeatByte(0, 100, 1000).ToArray(); 37 | 38 | var result1 = Enumerable.Min(array); 39 | var result2 = BurstLinqExtensions.Min(array); 40 | 41 | Assert.AreEqual(result1, result2); 42 | } 43 | } 44 | 45 | [Test] 46 | public void Test_Array_SByte() 47 | { 48 | for (int i = 0; i < 1000; i++) 49 | { 50 | var array = RandomEnumerable.RepeatSByte(0, 100, 1000).ToArray(); 51 | 52 | var result1 = Enumerable.Min(array); 53 | var result2 = BurstLinqExtensions.Min(array); 54 | 55 | Assert.AreEqual(result1, result2); 56 | } 57 | } 58 | 59 | [Test] 60 | public void Test_Array_Short() 61 | { 62 | for (int i = 0; i < 1000; i++) 63 | { 64 | var array = RandomEnumerable.RepeatShort(0, 100, 1000).ToArray(); 65 | 66 | var result1 = Enumerable.Min(array); 67 | var result2 = BurstLinqExtensions.Min(array); 68 | 69 | Assert.AreEqual(result1, result2); 70 | } 71 | } 72 | 73 | [Test] 74 | public void Test_Array_UShort() 75 | { 76 | for (int i = 0; i < 1000; i++) 77 | { 78 | var array = RandomEnumerable.RepeatUShort(0, 100, 1000).ToArray(); 79 | 80 | var result1 = Enumerable.Min(array); 81 | var result2 = BurstLinqExtensions.Min(array); 82 | 83 | Assert.AreEqual(result1, result2); 84 | } 85 | } 86 | 87 | [Test] 88 | public void Test_Array_Int() 89 | { 90 | for (int i = 0; i < 1000; i++) 91 | { 92 | var array = RandomEnumerable.RepeatInt(0, 100, 1000).ToArray(); 93 | 94 | var result1 = Enumerable.Min(array); 95 | var result2 = BurstLinqExtensions.Min(array); 96 | 97 | Assert.AreEqual(result1, result2); 98 | } 99 | } 100 | 101 | [Test] 102 | public void Test_Array_UInt() 103 | { 104 | for (int i = 0; i < 1000; i++) 105 | { 106 | var array = RandomEnumerable.RepeatUInt(0, 100, 1000).ToArray(); 107 | 108 | var result1 = Enumerable.Min(array); 109 | var result2 = BurstLinqExtensions.Min(array); 110 | 111 | Assert.AreEqual(result1, result2); 112 | } 113 | } 114 | 115 | [Test] 116 | public void Test_Array_Long() 117 | { 118 | for (int i = 0; i < 1000; i++) 119 | { 120 | var array = RandomEnumerable.RepeatLong(0, 100, 1000).ToArray(); 121 | 122 | var result1 = Enumerable.Min(array); 123 | var result2 = BurstLinqExtensions.Min(array); 124 | 125 | Assert.AreEqual(result1, result2); 126 | } 127 | } 128 | 129 | [Test] 130 | public void Test_Array_ULong() 131 | { 132 | for (int i = 0; i < 1000; i++) 133 | { 134 | var array = RandomEnumerable.RepeatULong(0, 100, 1000).ToArray(); 135 | 136 | var result1 = Enumerable.Min(array); 137 | var result2 = BurstLinqExtensions.Min(array); 138 | 139 | Assert.AreEqual(result1, result2); 140 | } 141 | } 142 | 143 | [Test] 144 | public void Test_Array_Float() 145 | { 146 | for (int i = 0; i < 1000; i++) 147 | { 148 | var array = RandomEnumerable.RepeatFloat(0, 100, 1000).ToArray(); 149 | 150 | var result1 = Enumerable.Min(array); 151 | var result2 = BurstLinqExtensions.Min(array); 152 | 153 | Assert.AreEqual(result1, result2); 154 | } 155 | } 156 | 157 | [Test] 158 | public void Test_Array_Double() 159 | { 160 | for (int i = 0; i < 1000; i++) 161 | { 162 | var array = RandomEnumerable.RepeatDouble(0, 100, 1000).ToArray(); 163 | 164 | var result1 = Enumerable.Min(array); 165 | var result2 = BurstLinqExtensions.Min(array); 166 | 167 | Assert.AreEqual(result1, result2); 168 | } 169 | } 170 | 171 | } 172 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Min.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double" 11 | }; 12 | 13 | string V256Name(string type) 14 | { 15 | switch (@type) 16 | { 17 | case "sbyte": return "SByte"; 18 | case "byte": return "Byte"; 19 | case "short": return "SShort"; 20 | case "ushort": return "UShort"; 21 | case "int": return "SInt"; 22 | case "uint": return "UInt"; 23 | case "long": return "SLong"; 24 | case "ulong": return "ULong"; 25 | case "float": return "Float"; 26 | case "double": return "Double"; 27 | } 28 | throw new Exception("Invalid type"); 29 | } 30 | 31 | int Size(string type) 32 | { 33 | switch (@type) 34 | { 35 | case "sbyte": return 1; 36 | case "byte": return 1; 37 | case "short": return 2; 38 | case "ushort": return 2; 39 | case "int": return 4; 40 | case "uint": return 4; 41 | case "long": return 8; 42 | case "ulong": return 8; 43 | case "float": return 4; 44 | case "double": return 8; 45 | } 46 | throw new Exception("Invalid type"); 47 | } 48 | 49 | bool IsFloating(string type) 50 | { 51 | return type is "float" or "double"; 52 | } 53 | #> 54 | using Unity.Burst; 55 | using Unity.Burst.CompilerServices; 56 | using Unity.Burst.Intrinsics; 57 | using Unity.Collections; 58 | using Unity.Collections.LowLevel.Unsafe; 59 | using Unity.Mathematics; 60 | using static Unity.Burst.Intrinsics.Arm.Neon; 61 | 62 | namespace BurstLinq 63 | { 64 | public unsafe static partial class BurstLinqExtensions 65 | { 66 | <# foreach(var type in types) { #> 67 | public static <#=type#> Min(this NativeList<<#=type#>> source) 68 | { 69 | Error.ThrowIfEmpty(source.Length); 70 | MinCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 71 | return result; 72 | } 73 | 74 | public static <#=type#> Min(this NativeSlice<<#=type#>> source) 75 | { 76 | Error.ThrowIfEmpty(source.Length); 77 | MinCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 78 | return result; 79 | } 80 | 81 | public static <#=type#> Min(this NativeArray<<#=type#>> source) 82 | { 83 | Error.ThrowIfEmpty(source.Length); 84 | MinCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 85 | return result; 86 | } 87 | 88 | [BurstCompile] 89 | internal static void MinCore(<#=type#>* ptr, [AssumeRange(1, int.MaxValue)] int length, out <#=type#> result) 90 | { 91 | var tempResult = <#=type#>.MaxValue; 92 | <# if (IsFloating(type)) {#> 93 | static <#=type#> _min(<#=type#> a, <#=type#> b) => IsNeonSupported ? math.min(a,b): a < b ? a : b; 94 | var index = 0; 95 | if (BurstHelpers.IsV256Supported) 96 | { 97 | static v256 _min256(v256 a, <#=type#>* b) => new v256( 98 | <# int vectorLength = 32 / Size(type); string typeName = V256Name(type); 99 | for (int i = 0; i < vectorLength - 1; i++) {#> 100 | _min(a.<#=typeName+i#>, b[<#=i#>]), 101 | <# } #> 102 | _min(a.<#=typeName+(vectorLength-1)#>, b[<#=(vectorLength-1)#>]) 103 | ); 104 | 105 | var packingLength = sizeof(v256) / sizeof(<#=type#>); 106 | 107 | if (0 < length / packingLength) 108 | { 109 | var temp = new v256(<#=type#>.MaxValue); 110 | for (; index < length - packingLength; index += packingLength) 111 | { 112 | temp = _min256(temp, ptr+index); 113 | } 114 | <#=type#>* tempAsArray = (<#=type#>*)&temp; 115 | for (int i = 0; i < packingLength; i++) 116 | { 117 | tempResult = _min(tempResult, tempAsArray[i]); 118 | } 119 | } 120 | } 121 | else if (BurstHelpers.IsV128Supported) 122 | { 123 | static v128 _min128(v128 a, <#=type#>* b) => new v128( 124 | <# for (int i =0;i 125 | _min(a.<#=typeName+i#>, b[<#=i#>]), 126 | <# } #> 127 | _min(a.<#=typeName+(vectorLength/2-1)#>, b[<#=vectorLength/2-1#>]) 128 | ); 129 | 130 | var packingLength = sizeof(v128) / sizeof(<#=type#>); 131 | 132 | if (0 < length / packingLength) 133 | { 134 | var temp = new v128(<#=type#>.MaxValue); 135 | for (; index < length - packingLength; index += packingLength) 136 | { 137 | temp = _min128(temp, ptr+index); 138 | } 139 | <#=type#>* tempAsArray = (<#=type#>*) &temp; 140 | for (int i = 0; i < packingLength; i++) 141 | { 142 | tempResult = _min(tempResult, tempAsArray[i]); 143 | } 144 | } 145 | } 146 | 147 | for (; index < length; index++) 148 | { 149 | tempResult = _min(tempResult, ptr[index]); 150 | } 151 | 152 | result = tempResult; 153 | <# } else {#> 154 | static <#=type#> _min(<#=type#> a, <#=type#> b) => a < b ? a : b; 155 | 156 | for (var i = 0; i < length; i++) 157 | { 158 | tempResult = _min(tempResult, ptr[i]); 159 | } 160 | 161 | result = tempResult; 162 | <# } #> 163 | } 164 | 165 | <# } #> 166 | 167 | } 168 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Max.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double" 11 | }; 12 | 13 | string V256Name(string type) 14 | { 15 | switch (@type) 16 | { 17 | case "sbyte": return "SByte"; 18 | case "byte": return "Byte"; 19 | case "short": return "SShort"; 20 | case "ushort": return "UShort"; 21 | case "int": return "SInt"; 22 | case "uint": return "UInt"; 23 | case "long": return "SLong"; 24 | case "ulong": return "ULong"; 25 | case "float": return "Float"; 26 | case "double": return "Double"; 27 | } 28 | throw new Exception("Invalid type"); 29 | } 30 | 31 | int Size(string type) 32 | { 33 | switch (@type) 34 | { 35 | case "sbyte": return 1; 36 | case "byte": return 1; 37 | case "short": return 2; 38 | case "ushort": return 2; 39 | case "int": return 4; 40 | case "uint": return 4; 41 | case "long": return 8; 42 | case "ulong": return 8; 43 | case "float": return 4; 44 | case "double": return 8; 45 | } 46 | throw new Exception("Invalid type"); 47 | } 48 | 49 | bool IsFloating(string type) 50 | { 51 | return type is "float" or "double"; 52 | } 53 | #> 54 | using Unity.Burst; 55 | using Unity.Burst.CompilerServices; 56 | using Unity.Burst.Intrinsics; 57 | using Unity.Collections; 58 | using Unity.Collections.LowLevel.Unsafe; 59 | using Unity.Mathematics; 60 | using static Unity.Burst.Intrinsics.Arm.Neon; 61 | 62 | namespace BurstLinq 63 | { 64 | public unsafe static partial class BurstLinqExtensions 65 | { 66 | <# foreach(var type in types) { #> 67 | public static <#=type#> Max(this NativeList<<#=type#>> source) 68 | { 69 | Error.ThrowIfEmpty(source.Length); 70 | MaxCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 71 | return result; 72 | } 73 | 74 | public static <#=type#> Max(this NativeSlice<<#=type#>> source) 75 | { 76 | Error.ThrowIfEmpty(source.Length); 77 | MaxCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 78 | return result; 79 | } 80 | 81 | public static <#=type#> Max(this NativeArray<<#=type#>> source) 82 | { 83 | Error.ThrowIfEmpty(source.Length); 84 | MaxCore((<#=type#>*)source.GetUnsafePtr(), source.Length, out var result); 85 | return result; 86 | } 87 | 88 | [BurstCompile] 89 | internal static void MaxCore(<#=type#>* ptr, [AssumeRange(1, int.MaxValue)] int length, out <#=type#> result) 90 | { 91 | var tempResult = <#=type#>.MinValue; 92 | <# if (IsFloating(type)) {#> 93 | static <#=type#> _max(<#=type#> a, <#=type#> b) => IsNeonSupported ? math.max(a,b) : a > b ? a : b; 94 | 95 | var index = 0; 96 | if (BurstHelpers.IsV256Supported) 97 | { 98 | static v256 _max256(v256 a, <#=type#>* b) => new v256( 99 | <#int vectorLength = 32 / Size(type); string typeName = V256Name(type); 100 | for (int i = 0; i < vectorLength - 1; i++) {#> 101 | _max(a.<#=typeName+i#>, b[<#=i#>]), 102 | <# } #> 103 | _max(a.<#=typeName+(vectorLength-1)#>, b[<#=(vectorLength-1)#>]) 104 | ); 105 | 106 | var packingLength = sizeof(v256) / sizeof(<#=type#>); 107 | 108 | if (0 < length / packingLength) 109 | { 110 | var temp = new v256(<#=type#>.MinValue); 111 | for (; index < length - packingLength; index += packingLength) 112 | { 113 | temp = _max256(temp, (ptr+index)); 114 | } 115 | <#=type#>* tempAsArray = (<#=type#>*)&temp; 116 | for (int i = 0; i < packingLength; i++) 117 | { 118 | tempResult = _max(tempResult, tempAsArray[i]); 119 | } 120 | } 121 | } 122 | else if (BurstHelpers.IsV128Supported) 123 | { 124 | static v128 _max128(v128 a, <#=type#>* b) => new v128( 125 | <# for (int i = 0; i < vectorLength / 2 - 1; i++) { #> 126 | _max(a.<#=typeName+i#>, b[<#=i#>]), 127 | <# } #> 128 | _max(a.<#=typeName+(vectorLength / 2 - 1)#>, b[<#=(vectorLength / 2 - 1)#>]) 129 | ); 130 | 131 | var packingLength = sizeof(v128) / sizeof(<#=type#>); 132 | 133 | if (0 < length / packingLength) 134 | { 135 | var temp = new v128(<#=type#>.MinValue); 136 | for (; index < length-packingLength; index+=packingLength) 137 | { 138 | temp = _max128(temp, ptr + index); 139 | } 140 | <#=type#>* tempAsArray = (<#=type#>*)&temp; 141 | for (int i = 0; i < packingLength; i++) 142 | { 143 | tempResult = _max(tempResult, tempAsArray[i]); 144 | } 145 | } 146 | } 147 | 148 | for (; index < length; index++) 149 | { 150 | tempResult = _max(tempResult, ptr[index]); 151 | } 152 | 153 | result = tempResult; 154 | <# } else {#> 155 | static <#=type#> _max(<#=type#> a, <#=type#> b) => a > b ? a : b; 156 | 157 | for (var i = 0; i < length; i++) 158 | { 159 | tempResult = _max(tempResult, ptr[i]); 160 | } 161 | 162 | result = tempResult; 163 | <# } #> 164 | } 165 | 166 | <# } #> 167 | } 168 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.SequenceEqual.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", 11 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 12 | "int2", "int3", "int4", 13 | "uint2", "uint3", "uint4", 14 | "float2", "float3", "float4", 15 | "double2", "double3", "double4", 16 | }; 17 | #> 18 | using System; 19 | using System.Collections.Generic; 20 | using Unity.Mathematics; 21 | using UnityEngine; 22 | 23 | namespace BurstLinq 24 | { 25 | public unsafe static partial class BurstLinqExtensions 26 | { 27 | <# foreach(var type in types) { #> 28 | public static bool SequenceEqual(this <#=type#>[] first, <#=type#>[] second) 29 | { 30 | Error.ThrowIfNull(first); 31 | Error.ThrowIfNull(second); 32 | 33 | if (first == second) return true; 34 | if (first.Length != second.Length) return false; 35 | 36 | fixed (<#=type#>* firstPtr = first, secondPtr = second) 37 | { 38 | return SequenceEqualCore(firstPtr, secondPtr, first.Length); 39 | } 40 | } 41 | 42 | public static bool SequenceEqual(this <#=type#>[] first, List<<#=type#>> second) 43 | { 44 | Error.ThrowIfNull(first); 45 | Error.ThrowIfNull(second); 46 | 47 | if (first.Length != second.Count) return false; 48 | 49 | var secondSpan = SpanHelper.AsSpan(second); 50 | fixed (<#=type#>* firstPtr = first, secondPtr = secondSpan) 51 | { 52 | return SequenceEqualCore(firstPtr, secondPtr, first.Length); 53 | } 54 | } 55 | 56 | public static bool SequenceEqual(this <#=type#>[] first, Memory<<#=type#>> second) 57 | { 58 | return SequenceEqual(first, (ReadOnlySpan<<#=type#>>)second.Span); 59 | } 60 | 61 | public static bool SequenceEqual(this <#=type#>[] first, ReadOnlyMemory<<#=type#>> second) 62 | { 63 | return SequenceEqual(first, second.Span); 64 | } 65 | 66 | public static bool SequenceEqual(this <#=type#>[] first, Span<<#=type#>> second) 67 | { 68 | return SequenceEqual(first, (ReadOnlySpan<<#=type#>>)second); 69 | } 70 | 71 | public static bool SequenceEqual(this <#=type#>[] first, ReadOnlySpan<<#=type#>> second) 72 | { 73 | Error.ThrowIfNull(first); 74 | 75 | if (first.Length != second.Length) return false; 76 | 77 | fixed (<#=type#>* firstPtr = first, secondPtr = second) 78 | { 79 | return SequenceEqualCore(firstPtr, secondPtr, first.Length); 80 | } 81 | } 82 | 83 | public static bool SequenceEqual(this List<<#=type#>> first, <#=type#>[] second) 84 | { 85 | return SequenceEqual(second, first); 86 | } 87 | 88 | public static bool SequenceEqual(this List<<#=type#>> first, List<<#=type#>> second) 89 | { 90 | Error.ThrowIfNull(first); 91 | Error.ThrowIfNull(second); 92 | 93 | if (first == second) return true; 94 | if (first.Count != second.Count) return false; 95 | 96 | var firstSpan = SpanHelper.AsSpan(first); 97 | var secondSpan = SpanHelper.AsSpan(second); 98 | fixed (<#=type#>* firstPtr = firstSpan, secondPtr = secondSpan) 99 | { 100 | return SequenceEqualCore(firstPtr, secondPtr, first.Count); 101 | } 102 | } 103 | 104 | public static bool SequenceEqual(this List<<#=type#>> first, Memory<<#=type#>> second) 105 | { 106 | return SequenceEqual(first, (ReadOnlySpan<<#=type#>>)second.Span); 107 | } 108 | 109 | public static bool SequenceEqual(this List<<#=type#>> first, ReadOnlyMemory<<#=type#>> second) 110 | { 111 | return SequenceEqual(first, second.Span); 112 | } 113 | 114 | public static bool SequenceEqual(this List<<#=type#>> first, Span<<#=type#>> second) 115 | { 116 | return SequenceEqual(first, (ReadOnlySpan<<#=type#>>)second); 117 | } 118 | 119 | public static bool SequenceEqual(this List<<#=type#>> first, ReadOnlySpan<<#=type#>> second) 120 | { 121 | Error.ThrowIfNull(first); 122 | 123 | if (first.Count != second.Length) return false; 124 | 125 | var firstSpan = SpanHelper.AsSpan(first); 126 | fixed (<#=type#>* firstPtr = firstSpan, secondPtr = second) 127 | { 128 | return SequenceEqualCore(firstPtr, secondPtr, first.Count); 129 | } 130 | } 131 | 132 | public static bool SequenceEqual(this Memory<<#=type#>> first, Memory<<#=type#>> second) 133 | { 134 | return SequenceEqual((ReadOnlySpan<<#=type#>>)first.Span, (ReadOnlySpan<<#=type#>>)second.Span); 135 | } 136 | 137 | public static bool SequenceEqual(this Memory<<#=type#>> first, ReadOnlyMemory<<#=type#>> second) 138 | { 139 | return SequenceEqual((ReadOnlySpan<<#=type#>>)first.Span, second.Span); 140 | } 141 | 142 | public static bool SequenceEqual(this ReadOnlyMemory<<#=type#>> first, ReadOnlyMemory<<#=type#>> second) 143 | { 144 | return SequenceEqual(first.Span, second.Span); 145 | } 146 | 147 | public static bool SequenceEqual(this Span<<#=type#>> first, Span<<#=type#>> second) 148 | { 149 | return SequenceEqual((ReadOnlySpan<<#=type#>>)first, (ReadOnlySpan<<#=type#>>)second); 150 | } 151 | 152 | public static bool SequenceEqual(this Span<<#=type#>> first, ReadOnlySpan<<#=type#>> second) 153 | { 154 | return SequenceEqual((ReadOnlySpan<<#=type#>>)first, second); 155 | } 156 | 157 | public static bool SequenceEqual(this ReadOnlySpan<<#=type#>> first, ReadOnlySpan<<#=type#>> second) 158 | { 159 | if (first.Length != second.Length) return false; 160 | 161 | fixed (<#=type#>* firstPtr = first, secondPtr = second) 162 | { 163 | return SequenceEqualCore(firstPtr, secondPtr, first.Length); 164 | } 165 | } 166 | <# } #> 167 | } 168 | } -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo 3DS: 5 223 | Nintendo Switch: 5 224 | PS4: 5 225 | PSP2: 2 226 | Stadia: 5 227 | Standalone: 5 228 | WebGL: 3 229 | Windows Store Apps: 5 230 | XboxOne: 5 231 | iPhone: 2 232 | tvOS: 2 233 | -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/BurstLinqExtensions.Native.Contains.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ output extension=".cs" #> 7 | <# 8 | var types = new string[] 9 | { 10 | "byte", "sbyte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", 11 | "Vector2", "Vector2Int", "Vector3", "Vector3Int", "Vector4", 12 | "int2", "int3", "int4", 13 | "uint2", "uint3", "uint4", 14 | "float2", "float3", "float4", 15 | "double2", "double3", "double4", 16 | }; 17 | 18 | bool IsPrimitive(string type) 19 | { 20 | return type is "byte"or "sbyte"or "short"or "ushort"or "int" or "uint" or "float" or "double" or "long" or "ulong"; 21 | } 22 | 23 | string V256Name(string type) 24 | { 25 | switch (@type) { 26 | case "sbyte": return "SByte"; 27 | case "byte": return "Byte"; 28 | case "short": return "SShort"; 29 | case "ushort": return "UShort"; 30 | case "int": return "SInt"; 31 | case "uint": return "UInt"; 32 | case "long": return "SLong"; 33 | case "ulong": return "ULong"; 34 | case "float": return "Float"; 35 | case "double": return "Double"; 36 | } 37 | throw new Exception("Invalid type"); 38 | } 39 | 40 | int Size(string type) 41 | { 42 | switch (@type) 43 | { 44 | case "sbyte": return 1; 45 | case "byte": return 1; 46 | case "short": return 2; 47 | case "ushort": return 2; 48 | case "int": return 4; 49 | case "uint": return 4; 50 | case "long": return 8; 51 | case "ulong": return 8; 52 | case "float": return 4; 53 | case "double": return 8; 54 | case "Vector2": return sizeof(float) * 2; 55 | case "Vector2Int": return sizeof(int) * 2; 56 | case "Vector3": return sizeof(float) * 3; 57 | case "Vector3Int": return sizeof(int) * 3; 58 | case "Vector4": return sizeof(float) * 4; 59 | case "int2": return sizeof(int) * 2; 60 | case "int3": return sizeof(int) * 3; 61 | case "int4": return sizeof(int) * 4; 62 | case "uint2": return sizeof(uint) * 2; 63 | case "uint3": return sizeof(uint) * 3; 64 | case "uint4": return sizeof(uint) * 4; 65 | case "float2": return sizeof(float) * 2; 66 | case "float3": return sizeof(float) * 3; 67 | case "float4": return sizeof(float) * 4; 68 | case "double2": return sizeof(double) * 2; 69 | case "double3": return sizeof(double) * 3; 70 | case "double4": return sizeof(double) * 4; 71 | } 72 | 73 | throw new Exception("Invalid type"); 74 | } 75 | 76 | bool TryGetInteger(string type, out string type2) 77 | { 78 | type2 = null; 79 | switch (type) 80 | { 81 | case "int2": type2 = "long"; return true; 82 | case "uint2": type2 = "long"; return true; 83 | case "Vector2Int": type2 = "long"; return true; 84 | default: return false; 85 | } 86 | } 87 | #> 88 | using Unity.Burst; 89 | using Unity.Burst.CompilerServices; 90 | using Unity.Burst.Intrinsics; 91 | using Unity.Collections; 92 | using Unity.Collections.LowLevel.Unsafe; 93 | using Unity.Mathematics; 94 | using UnityEngine; 95 | using System.Runtime.CompilerServices; 96 | namespace BurstLinq 97 | { 98 | public unsafe static partial class BurstLinqExtensions 99 | { 100 | <# foreach(var type in types) { #> 101 | public static bool Contains(this NativeList<<#=type#>> source, <#=type#> value) 102 | { 103 | return ContainsCore((<#=type#>*)source.GetUnsafePtr(), source.Length, value); 104 | } 105 | 106 | public static bool Contains(this NativeSlice<<#=type#>> source, <#=type#> value) 107 | { 108 | return ContainsCore((<#=type#>*)source.GetUnsafePtr(), source.Length, value); 109 | } 110 | 111 | public static bool Contains(this NativeArray<<#=type#>> source, <#=type#> value) 112 | { 113 | return ContainsCore((<#=type#>*)source.GetUnsafePtr(), source.Length, value); 114 | } 115 | 116 | <#if (TryGetInteger(type, out var intType)){#> 117 | internal static bool ContainsCore(<#=type#>* ptr, [AssumeRange(1, int.MaxValue)] int length, in <#=type#> value) 118 | { 119 | var temp = value; 120 | var union = *(<#=intType#>*)&temp; 121 | return ContainsCore((<#=intType#>*)ptr, length, union); 122 | } 123 | <#} else if (IsPrimitive(type)) { #> 124 | <#var vName = V256Name(type);#> 125 | [BurstCompile] 126 | internal static bool ContainsCore(<#=type#>* ptr, [AssumeRange(1, int.MaxValue)] int length, in <#=type#> value) 127 | { 128 | var index = 0; 129 | if (BurstHelpers.IsV256Supported) 130 | { 131 | const int packingLength = 32 / sizeof(<#=type#>); 132 | 133 | <# int vectorLength=32/Size(type);string typeName = V256Name(type);#> 134 | static bool<#=vectorLength#> _contains(v256 a, <#=type#>* b) => new bool<#=vectorLength#>( 135 | <# for (int i =0;i 136 | a.<#=typeName+i#> == b[<#=i#>], 137 | <# } #> 138 | a.<#=typeName+(vectorLength-1)#> == b[<#=vectorLength-1#>] 139 | ); 140 | 141 | if (0 < length / packingLength) 142 | { 143 | var valueVector = new v256(value); 144 | for (; index < length-packingLength; index += packingLength) 145 | { 146 | if(_contains(valueVector, ptr + index).any()) return true; 147 | } 148 | } 149 | } 150 | else if (BurstHelpers.IsV128Supported) 151 | { 152 | const int packingLength = 16 / sizeof(<#=type#>); 153 | 154 | static bool<#=vectorLength/2#> _contains(v128 a, <#=type#>* b) => new bool<#=vectorLength/2#>( 155 | <# for (int i = 0; i < vectorLength / 2 - 1; i++) {#> 156 | a.<#=typeName + i#> == b[<#=i#>], 157 | <# } #> 158 | a.<#=typeName + (vectorLength / 2 - 1)#> == b[<#=vectorLength / 2 - 1#>] 159 | ); 160 | 161 | if (0 < length / packingLength) 162 | { 163 | var valueVector = new v128(value); 164 | for (; index < length - packingLength; index += packingLength) 165 | { 166 | if(_contains(valueVector, ptr + index).any()) return true; 167 | } 168 | } 169 | } 170 | 171 | for (; index < length; index++) 172 | { 173 | if (ptr[index] == value) return true; 174 | } 175 | 176 | return false; 177 | } 178 | <#} else { #> 179 | [BurstCompile] 180 | internal static bool ContainsCore(<#=type#>* ptr, [AssumeRange(0, int.MaxValue)] int length, in <#=type#> value) 181 | { 182 | for (int i = 0; i < length; i++) 183 | { 184 | if (ptr[i].Equals(value)) return true; 185 | } 186 | 187 | return false; 188 | } 189 | <# } #> 190 | <# } #> 191 | 192 | } 193 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Runtime/Vectors.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Unity.Mathematics; 5 | 6 | namespace BurstLinq 7 | { 8 | internal static class VectorExtensions 9 | { 10 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 11 | public static bool any(this bool2 v) => v.x || v.y; 12 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 13 | public static bool any(this bool3 v) => v.x || v.y || v.z; 14 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 15 | public static bool any(this bool4 v) => v.x || v.y || v.z || v.w; 16 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 17 | public static bool all(this bool2 v) => v.x && v.y; 18 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 19 | public static bool all(this bool3 v) => v.x && v.y && v.z; 20 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 21 | public static bool all(this bool4 v) => v.x && v.y && v.z && v.w; 22 | } 23 | 24 | [Serializable] 25 | [StructLayout(LayoutKind.Explicit, Size = 32 * sizeof(bool))] 26 | internal struct bool32 27 | { 28 | [FieldOffset(0)] 29 | public bool x0; 30 | 31 | [FieldOffset(1)] 32 | public bool x1; 33 | 34 | [FieldOffset(2)] 35 | public bool x2; 36 | 37 | [FieldOffset(3)] 38 | public bool x3; 39 | 40 | [FieldOffset(4)] 41 | public bool x4; 42 | 43 | [FieldOffset(5)] 44 | public bool x5; 45 | 46 | [FieldOffset(6)] 47 | public bool x6; 48 | 49 | [FieldOffset(7)] 50 | public bool x7; 51 | 52 | [FieldOffset(8)] 53 | public bool x8; 54 | 55 | [FieldOffset(9)] 56 | public bool x9; 57 | 58 | [FieldOffset(10)] 59 | public bool x10; 60 | 61 | [FieldOffset(11)] 62 | public bool x11; 63 | 64 | [FieldOffset(12)] 65 | public bool x12; 66 | 67 | [FieldOffset(13)] 68 | public bool x13; 69 | 70 | [FieldOffset(14)] 71 | public bool x14; 72 | 73 | [FieldOffset(15)] 74 | public bool x15; 75 | 76 | [FieldOffset(16)] 77 | public bool x16; 78 | 79 | [FieldOffset(17)] 80 | public bool x17; 81 | 82 | [FieldOffset(18)] 83 | public bool x18; 84 | 85 | [FieldOffset(19)] 86 | public bool x19; 87 | 88 | [FieldOffset(20)] 89 | public bool x20; 90 | 91 | [FieldOffset(21)] 92 | public bool x21; 93 | 94 | [FieldOffset(22)] 95 | public bool x22; 96 | 97 | [FieldOffset(23)] 98 | public bool x23; 99 | 100 | [FieldOffset(24)] 101 | public bool x24; 102 | 103 | [FieldOffset(25)] 104 | public bool x25; 105 | 106 | [FieldOffset(26)] 107 | public bool x26; 108 | 109 | [FieldOffset(27)] 110 | public bool x27; 111 | 112 | [FieldOffset(28)] 113 | public bool x28; 114 | 115 | [FieldOffset(29)] 116 | public bool x29; 117 | 118 | [FieldOffset(30)] 119 | public bool x30; 120 | 121 | [FieldOffset(31)] 122 | public bool x31; 123 | 124 | public bool32(bool x0, bool x1, bool x2, bool x3, bool x4, bool x5, bool x6, bool x7, bool x8, bool x9, bool x10, bool x11, bool x12, bool x13, bool x14, bool x15, bool x16, bool x17, bool x18, bool x19, bool x20, bool x21, bool x22, bool x23, bool x24, bool x25, bool x26, bool x27, bool x28, bool x29, bool x30, bool x31) 125 | { 126 | this.x0 = x0; 127 | this.x1 = x1; 128 | this.x2 = x2; 129 | this.x3 = x3; 130 | this.x4 = x4; 131 | this.x5 = x5; 132 | this.x6 = x6; 133 | this.x7 = x7; 134 | this.x8 = x8; 135 | this.x9 = x9; 136 | this.x10 = x10; 137 | this.x11 = x11; 138 | this.x12 = x12; 139 | this.x13 = x13; 140 | this.x14 = x14; 141 | this.x15 = x15; 142 | this.x16 = x16; 143 | this.x17 = x17; 144 | this.x18 = x18; 145 | this.x19 = x19; 146 | this.x20 = x20; 147 | this.x21 = x21; 148 | this.x22 = x22; 149 | this.x23 = x23; 150 | this.x24 = x24; 151 | this.x25 = x25; 152 | this.x26 = x26; 153 | this.x27 = x27; 154 | this.x28 = x28; 155 | this.x29 = x29; 156 | this.x30 = x30; 157 | this.x31 = x31; 158 | } 159 | 160 | public bool any() => x0 || x1 || x2 || x3 || x4 || x5 || x6 || x7 || x8 || x9 || x10 || x11 || x12 || x13 || x14 || x15 || x16 || x17 || x18 || x19 || x20 || x21 || x22 || x23 || x24 || x25 || x26 || x27 || x28 || x29 || x30 || x31; 161 | public bool all() => x0 && x1 && x2 && x3 && x4 && x5 && x6 && x7 && x8 && x9 && x10 && x11 && x12 && x13 && x14 && x15 && x16 && x17 && x18 && x19 && x20 && x21 && x22 && x23 && x24 && x25 && x26 && x27 && x28 && x29 && x30 && x31; 162 | } 163 | 164 | [Serializable] 165 | [StructLayout(LayoutKind.Explicit, Size = 16 * sizeof(bool))] 166 | internal struct bool16 167 | { 168 | [FieldOffset(0)] 169 | public bool x0; 170 | 171 | [FieldOffset(1)] 172 | public bool x1; 173 | 174 | [FieldOffset(2)] 175 | public bool x2; 176 | 177 | [FieldOffset(3)] 178 | public bool x3; 179 | 180 | [FieldOffset(4)] 181 | public bool x4; 182 | 183 | [FieldOffset(5)] 184 | public bool x5; 185 | 186 | [FieldOffset(6)] 187 | public bool x6; 188 | 189 | [FieldOffset(7)] 190 | public bool x7; 191 | 192 | [FieldOffset(8)] 193 | public bool x8; 194 | 195 | [FieldOffset(9)] 196 | public bool x9; 197 | 198 | [FieldOffset(10)] 199 | 200 | public bool x10; 201 | 202 | [FieldOffset(11)] 203 | 204 | public bool x11; 205 | 206 | [FieldOffset(12)] 207 | 208 | public bool x12; 209 | 210 | [FieldOffset(13)] 211 | 212 | public bool x13; 213 | 214 | [FieldOffset(14)] 215 | 216 | public bool x14; 217 | 218 | [FieldOffset(15)] 219 | 220 | public bool x15; 221 | 222 | public bool16(bool x0, bool x1, bool x2, bool x3, bool x4, bool x5, bool x6, bool x7, bool x8, bool x9, bool x10, bool x11, bool x12, bool x13, bool x14, bool x15) 223 | { 224 | this.x0 = x0; 225 | this.x1 = x1; 226 | this.x2 = x2; 227 | this.x3 = x3; 228 | this.x4 = x4; 229 | this.x5 = x5; 230 | this.x6 = x6; 231 | this.x7 = x7; 232 | this.x8 = x8; 233 | this.x9 = x9; 234 | this.x10 = x10; 235 | this.x11 = x11; 236 | this.x12 = x12; 237 | this.x13 = x13; 238 | this.x14 = x14; 239 | this.x15 = x15; 240 | } 241 | 242 | 243 | public bool any() => x0 || x1 || x2 || x3 || x4 || x5 || x6 || x7 || x8 || x9 || x10 || x11 || x12 || x13 || x14 || x15; 244 | public bool all() => x0 && x1 && x2 && x3 && x4 && x5 && x6 && x7 || x8 && x9 && x10 && x11 && x12 && x13 && x14 && x15; 245 | } 246 | 247 | [Serializable] 248 | [StructLayout(LayoutKind.Explicit, Size = 8 * sizeof(bool))] 249 | internal struct bool8 250 | { 251 | [FieldOffset(0)] 252 | public bool x0; 253 | 254 | [FieldOffset(1)] 255 | public bool x1; 256 | 257 | [FieldOffset(2)] 258 | public bool x2; 259 | 260 | [FieldOffset(3)] 261 | public bool x3; 262 | 263 | [FieldOffset(4)] 264 | public bool x4; 265 | 266 | [FieldOffset(5)] 267 | public bool x5; 268 | 269 | [FieldOffset(6)] 270 | public bool x6; 271 | 272 | [FieldOffset(7)] 273 | public bool x7; 274 | public bool8(bool x0, bool x1, bool x2, bool x3, bool x4, bool x5, bool x6, bool x7) 275 | { 276 | this.x0 = x0; 277 | this.x1 = x1; 278 | this.x2 = x2; 279 | this.x3 = x3; 280 | this.x4 = x4; 281 | this.x5 = x5; 282 | this.x6 = x6; 283 | this.x7 = x7; 284 | } 285 | 286 | public bool any() => x0 || x1 || x2 || x3 || x4 || x5 || x6 || x7; 287 | public bool all() => x0 && x1 && x2 && x3 && x4 && x5 && x6 && x7; 288 | } 289 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/Benchmark.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using NUnit.Framework; 5 | using Unity.PerformanceTesting; 6 | 7 | #pragma warning disable CS0219 8 | 9 | namespace BurstLinq.Tests 10 | { 11 | public class BenchmarkFloatSum 12 | { 13 | const int WarmupCount = 5; 14 | const int MeasurementCount = 100; 15 | 16 | static readonly float[] array = Enumerable.Repeat(1.0f, 10000).ToArray(); 17 | 18 | [TearDown] 19 | public void TearDown() 20 | { 21 | GC.Collect(); 22 | } 23 | 24 | [Test, Performance] 25 | public void For() 26 | { 27 | Measure.Method(() => 28 | { 29 | if (array == null) return; 30 | 31 | var result = 0.0f; 32 | for (int i = 0; i < array.Length; i++) 33 | { 34 | result += array[i]; 35 | } 36 | }) 37 | .WarmupCount(WarmupCount) 38 | .MeasurementCount(MeasurementCount) 39 | .SampleGroup(new SampleGroup("Float Sum: For", SampleUnit.Microsecond)) 40 | .Run(); 41 | } 42 | 43 | [Test, Performance] 44 | public void LINQ() 45 | { 46 | Measure.Method(() => 47 | { 48 | Enumerable.Sum(array); 49 | }) 50 | .WarmupCount(WarmupCount) 51 | .MeasurementCount(MeasurementCount) 52 | .SampleGroup(new SampleGroup("Float Sum: LINQ", SampleUnit.Microsecond)) 53 | .Run(); 54 | } 55 | 56 | [Test, Performance] 57 | public void BurstLinq() 58 | { 59 | Measure.Method(() => 60 | { 61 | BurstLinqExtensions.Sum(array); 62 | }) 63 | .WarmupCount(WarmupCount) 64 | .MeasurementCount(MeasurementCount) 65 | .SampleGroup(new SampleGroup("Float Sum: BurstLinq", SampleUnit.Microsecond)) 66 | .Run(); 67 | } 68 | } 69 | 70 | public class BenchmarkIntSequenceEqual 71 | { 72 | const int WarmupCount = 5; 73 | const int MeasurementCount = 100; 74 | 75 | static readonly int[] array1 = Enumerable.Range(0, 10000).ToArray(); 76 | static readonly int[] array2 = Enumerable.Range(0, 10000).ToArray(); 77 | 78 | [TearDown] 79 | public void TearDown() 80 | { 81 | GC.Collect(); 82 | } 83 | 84 | [Test, Performance] 85 | public void For() 86 | { 87 | Measure.Method(() => 88 | { 89 | if (array1 == null) return; 90 | if (array2 == null) return; 91 | 92 | var result = true; 93 | if (array1.Length != array2.Length) 94 | { 95 | result = false; 96 | return; 97 | } 98 | 99 | for (int i = 0; i < array1.Length; i++) 100 | { 101 | if (array1[i] != array2[i]) 102 | { 103 | result = false; 104 | break; 105 | } 106 | } 107 | }) 108 | .WarmupCount(WarmupCount) 109 | .MeasurementCount(MeasurementCount) 110 | .SampleGroup(new SampleGroup("Int SequenceEqual: For", SampleUnit.Microsecond)) 111 | .Run(); 112 | } 113 | 114 | [Test, Performance] 115 | public void LINQ() 116 | { 117 | Measure.Method(() => 118 | { 119 | Enumerable.SequenceEqual(array1, array2); 120 | }) 121 | .WarmupCount(WarmupCount) 122 | .MeasurementCount(MeasurementCount) 123 | .SampleGroup(new SampleGroup("Int SequenceEqual: LINQ", SampleUnit.Microsecond)) 124 | .Run(); 125 | } 126 | 127 | [Test, Performance] 128 | public void BurstLinq() 129 | { 130 | Measure.Method(() => 131 | { 132 | BurstLinqExtensions.SequenceEqual(array1, array2); 133 | }) 134 | .WarmupCount(WarmupCount) 135 | .MeasurementCount(MeasurementCount) 136 | .SampleGroup(new SampleGroup("Int SequenceEqual: BurstLinq", SampleUnit.Microsecond)) 137 | .Run(); 138 | } 139 | } 140 | 141 | public class BenchmarkDoubleMin 142 | { 143 | const int WarmupCount = 5; 144 | const int MeasurementCount = 100; 145 | 146 | static readonly double[] array = DoubleRange(10000).ToArray(); 147 | static IEnumerable DoubleRange(int count) 148 | { 149 | var current = 0.0; 150 | for (int i = 0; i < count; i++) yield return current++; 151 | } 152 | 153 | [TearDown] 154 | public void TearDown() 155 | { 156 | GC.Collect(); 157 | } 158 | 159 | [Test, Performance] 160 | public void For() 161 | { 162 | Measure.Method(() => 163 | { 164 | if (array == null) return; 165 | 166 | var result = double.MaxValue; 167 | for (int i = 0; i < array.Length; i++) 168 | { 169 | if (array[i] < result) result = array[i]; 170 | } 171 | }) 172 | .WarmupCount(WarmupCount) 173 | .MeasurementCount(MeasurementCount) 174 | .SampleGroup(new SampleGroup("Double Min: For", SampleUnit.Microsecond)) 175 | .Run(); 176 | } 177 | 178 | [Test, Performance] 179 | public void LINQ() 180 | { 181 | Measure.Method(() => 182 | { 183 | Enumerable.Min(array); 184 | }) 185 | .WarmupCount(WarmupCount) 186 | .MeasurementCount(MeasurementCount) 187 | .SampleGroup(new SampleGroup("Double Min: LINQ", SampleUnit.Microsecond)) 188 | .Run(); 189 | } 190 | 191 | [Test, Performance] 192 | public void BurstLinq() 193 | { 194 | Measure.Method(() => 195 | { 196 | BurstLinqExtensions.Min(array); 197 | }) 198 | .WarmupCount(WarmupCount) 199 | .MeasurementCount(MeasurementCount) 200 | .SampleGroup(new SampleGroup("Double Min: BurstLinq", SampleUnit.Microsecond)) 201 | .Run(); 202 | } 203 | } 204 | 205 | public class BenchmarkIntMin 206 | { 207 | const int WarmupCount = 5; 208 | const int MeasurementCount = 100; 209 | 210 | static readonly int[] array = Enumerable.Range(0, 10000).ToArray(); 211 | 212 | [TearDown] 213 | public void TearDown() 214 | { 215 | GC.Collect(); 216 | } 217 | 218 | [Test, Performance] 219 | public void For() 220 | { 221 | Measure.Method(() => 222 | { 223 | if (array == null) return; 224 | 225 | var result = int.MaxValue; 226 | for (int i = 0; i < array.Length; i++) 227 | { 228 | if (array[i] < result) result = array[i]; 229 | } 230 | }) 231 | .WarmupCount(WarmupCount) 232 | .MeasurementCount(MeasurementCount) 233 | .SampleGroup(new SampleGroup("Int Min: For", SampleUnit.Microsecond)) 234 | .Run(); 235 | } 236 | 237 | [Test, Performance] 238 | public void LINQ() 239 | { 240 | Measure.Method(() => 241 | { 242 | Enumerable.Min(array); 243 | }) 244 | .WarmupCount(WarmupCount) 245 | .MeasurementCount(MeasurementCount) 246 | .SampleGroup(new SampleGroup("Int Min: LINQ", SampleUnit.Microsecond)) 247 | .Run(); 248 | } 249 | 250 | [Test, Performance] 251 | public void BurstLinq() 252 | { 253 | Measure.Method(() => 254 | { 255 | BurstLinqExtensions.Min(array); 256 | }) 257 | .WarmupCount(WarmupCount) 258 | .MeasurementCount(MeasurementCount) 259 | .SampleGroup(new SampleGroup("Int Min: BurstLinq", SampleUnit.Microsecond)) 260 | .Run(); 261 | } 262 | } 263 | 264 | 265 | public class BenchmarkIntContains 266 | { 267 | const int WarmupCount = 5; 268 | const int MeasurementCount = 100; 269 | 270 | static readonly int[] array = Enumerable.Range(0, 10000).ToArray(); 271 | 272 | [TearDown] 273 | public void TearDown() 274 | { 275 | GC.Collect(); 276 | } 277 | 278 | [Test, Performance] 279 | public void For() 280 | { 281 | Measure.Method(() => 282 | { 283 | if (array == null) return; 284 | 285 | var value = array.Last(); 286 | var result = false; 287 | for (int i = 0; i < array.Length; i++) 288 | { 289 | if (array[i] == value) 290 | { 291 | result = true; 292 | break; 293 | } 294 | } 295 | }) 296 | .WarmupCount(WarmupCount) 297 | .MeasurementCount(MeasurementCount) 298 | .SampleGroup(new SampleGroup("Int Contains: For", SampleUnit.Microsecond)) 299 | .Run(); 300 | } 301 | 302 | [Test, Performance] 303 | public void LINQ() 304 | { 305 | Measure.Method(() => 306 | { 307 | Enumerable.Contains(array, array.Last()); 308 | }) 309 | .WarmupCount(WarmupCount) 310 | .MeasurementCount(MeasurementCount) 311 | .SampleGroup(new SampleGroup("Int Contains: LINQ", SampleUnit.Microsecond)) 312 | .Run(); 313 | } 314 | 315 | [Test, Performance] 316 | public void BurstLinq() 317 | { 318 | Measure.Method(() => 319 | { 320 | BurstLinqExtensions.Contains(array, array.Last()); 321 | }) 322 | .WarmupCount(WarmupCount) 323 | .MeasurementCount(MeasurementCount) 324 | .SampleGroup(new SampleGroup("Int Contains: BurstLinq", SampleUnit.Microsecond)) 325 | .Run(); 326 | } 327 | } 328 | 329 | } 330 | 331 | #pragma warning restore CS0219 -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/AverageTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using NUnit.Framework; 4 | using UnityEngine; 5 | using Unity.Mathematics; 6 | using Assert = UnityEngine.Assertions.Assert; 7 | using Random = UnityEngine.Random; 8 | 9 | namespace BurstLinq.Tests 10 | { 11 | public class AverageTest 12 | { 13 | [SetUp] 14 | public void SetUp() 15 | { 16 | Random.InitState((int)DateTime.Now.Ticks); 17 | } 18 | 19 | [Test] 20 | public void Test_List() 21 | { 22 | for (int i = 0; i < 100; i++) 23 | { 24 | var list = RandomEnumerable.RepeatInt(0, 100, 1000).ToList(); 25 | 26 | var result1 = Enumerable.Average(list); 27 | var result2 = BurstLinqExtensions.Average(list); 28 | 29 | Assert.AreEqual(result1, result2); 30 | } 31 | } 32 | 33 | [Test] 34 | public void Test_Array_Int() 35 | { 36 | for (int i = 0; i < 1000; i++) 37 | { 38 | var array = RandomEnumerable.RepeatInt(0, 100, 1000).ToArray(); 39 | 40 | var result1 = Enumerable.Average(array); 41 | var result2 = BurstLinqExtensions.Average(array); 42 | 43 | AssertEx.AreApproximatelyEqual(result1, result2); 44 | } 45 | } 46 | 47 | [Test] 48 | public void Test_Array_UInt() 49 | { 50 | for (int i = 0; i < 1000; i++) 51 | { 52 | var array = RandomEnumerable.RepeatUInt(0, 100, 1000).ToArray(); 53 | 54 | uint sum = default; 55 | for (int n = 0; n < array.Length; n++) sum += array[n]; 56 | var result1 = (double)sum / array.Length; 57 | var result2 = BurstLinqExtensions.Average(array); 58 | 59 | AssertEx.AreApproximatelyEqual(result1, result2); 60 | } 61 | } 62 | 63 | [Test] 64 | public void Test_Array_Long() 65 | { 66 | for (int i = 0; i < 1000; i++) 67 | { 68 | var array = RandomEnumerable.RepeatLong(0, 100, 1000).ToArray(); 69 | 70 | var result1 = Enumerable.Average(array); 71 | var result2 = BurstLinqExtensions.Average(array); 72 | 73 | AssertEx.AreApproximatelyEqual(result1, result2); 74 | } 75 | } 76 | 77 | [Test] 78 | public void Test_Array_ULong() 79 | { 80 | for (int i = 0; i < 1000; i++) 81 | { 82 | var array = RandomEnumerable.RepeatULong(0, 100, 1000).ToArray(); 83 | 84 | ulong sum = default; 85 | for (int n = 0; n < array.Length; n++) sum += array[n]; 86 | var result1 = (double)sum / array.Length; 87 | var result2 = BurstLinqExtensions.Average(array); 88 | 89 | AssertEx.AreApproximatelyEqual(result1, result2); 90 | } 91 | } 92 | 93 | [Test] 94 | public void Test_Array_Float() 95 | { 96 | for (int i = 0; i < 1000; i++) 97 | { 98 | var array = RandomEnumerable.RepeatFloat(0, 100, 1000).ToArray(); 99 | 100 | var result1 = Enumerable.Average(array); 101 | var result2 = BurstLinqExtensions.Average(array); 102 | 103 | AssertEx.AreApproximatelyEqual(result1, result2); 104 | } 105 | } 106 | 107 | [Test] 108 | public void Test_Array_Double() 109 | { 110 | for (int i = 0; i < 1000; i++) 111 | { 112 | var array = RandomEnumerable.RepeatDouble(0, 100, 1000).ToArray(); 113 | 114 | var result1 = Enumerable.Average(array); 115 | var result2 = BurstLinqExtensions.Average(array); 116 | 117 | AssertEx.AreApproximatelyEqual(result1, result2); 118 | } 119 | } 120 | 121 | [Test] 122 | public void Test_Array_Vector2() 123 | { 124 | for (int i = 0; i < 1000; i++) 125 | { 126 | var array = RandomEnumerable.RepeatVector2(0, 100, 1000).ToArray(); 127 | 128 | Vector2 sum = default; 129 | for (int n = 0; n < array.Length; n++) sum += array[n]; 130 | var result1 = (Vector2)sum / array.Length; 131 | var result2 = BurstLinqExtensions.Average(array); 132 | 133 | AssertEx.AreApproximatelyEqual(result1, result2); 134 | } 135 | } 136 | 137 | [Test] 138 | public void Test_Array_Vector2Int() 139 | { 140 | for (int i = 0; i < 1000; i++) 141 | { 142 | var array = RandomEnumerable.RepeatVector2Int(0, 100, 1000).ToArray(); 143 | 144 | Vector2Int sum = default; 145 | for (int n = 0; n < array.Length; n++) sum += array[n]; 146 | var result1 = (Vector2)sum / array.Length; 147 | var result2 = BurstLinqExtensions.Average(array); 148 | 149 | AssertEx.AreApproximatelyEqual(result1, result2); 150 | } 151 | } 152 | 153 | [Test] 154 | public void Test_Array_Vector3() 155 | { 156 | for (int i = 0; i < 1000; i++) 157 | { 158 | var array = RandomEnumerable.RepeatVector3(0, 100, 1000).ToArray(); 159 | 160 | Vector3 sum = default; 161 | for (int n = 0; n < array.Length; n++) sum += array[n]; 162 | var result1 = (Vector3)sum / array.Length; 163 | var result2 = BurstLinqExtensions.Average(array); 164 | 165 | AssertEx.AreApproximatelyEqual(result1, result2); 166 | } 167 | } 168 | 169 | [Test] 170 | public void Test_Array_Vector3Int() 171 | { 172 | for (int i = 0; i < 1000; i++) 173 | { 174 | var array = RandomEnumerable.RepeatVector3Int(0, 100, 1000).ToArray(); 175 | 176 | Vector3Int sum = default; 177 | for (int n = 0; n < array.Length; n++) sum += array[n]; 178 | var result1 = (Vector3)sum / array.Length; 179 | var result2 = BurstLinqExtensions.Average(array); 180 | 181 | AssertEx.AreApproximatelyEqual(result1, result2); 182 | } 183 | } 184 | 185 | [Test] 186 | public void Test_Array_Vector4() 187 | { 188 | for (int i = 0; i < 1000; i++) 189 | { 190 | var array = RandomEnumerable.RepeatVector4(0, 100, 1000).ToArray(); 191 | 192 | Vector4 sum = default; 193 | for (int n = 0; n < array.Length; n++) sum += array[n]; 194 | var result1 = (Vector4)sum / array.Length; 195 | var result2 = BurstLinqExtensions.Average(array); 196 | 197 | AssertEx.AreApproximatelyEqual(result1, result2); 198 | } 199 | } 200 | 201 | [Test] 202 | public void Test_Array_Int2() 203 | { 204 | for (int i = 0; i < 1000; i++) 205 | { 206 | var array = RandomEnumerable.RepeatInt2(0, 100, 1000).ToArray(); 207 | 208 | int2 sum = default; 209 | for (int n = 0; n < array.Length; n++) sum += array[n]; 210 | var result1 = (double2)sum / array.Length; 211 | var result2 = BurstLinqExtensions.Average(array); 212 | 213 | AssertEx.AreApproximatelyEqual(result1, result2); 214 | } 215 | } 216 | 217 | [Test] 218 | public void Test_Array_Int3() 219 | { 220 | for (int i = 0; i < 1000; i++) 221 | { 222 | var array = RandomEnumerable.RepeatInt3(0, 100, 1000).ToArray(); 223 | 224 | int3 sum = default; 225 | for (int n = 0; n < array.Length; n++) sum += array[n]; 226 | var result1 = (double3)sum / array.Length; 227 | var result2 = BurstLinqExtensions.Average(array); 228 | 229 | AssertEx.AreApproximatelyEqual(result1, result2); 230 | } 231 | } 232 | 233 | [Test] 234 | public void Test_Array_Int4() 235 | { 236 | for (int i = 0; i < 1000; i++) 237 | { 238 | var array = RandomEnumerable.RepeatInt4(0, 100, 1000).ToArray(); 239 | 240 | int4 sum = default; 241 | for (int n = 0; n < array.Length; n++) sum += array[n]; 242 | var result1 = (double4)sum / array.Length; 243 | var result2 = BurstLinqExtensions.Average(array); 244 | 245 | AssertEx.AreApproximatelyEqual(result1, result2); 246 | } 247 | } 248 | 249 | [Test] 250 | public void Test_Array_Float2() 251 | { 252 | for (int i = 0; i < 1000; i++) 253 | { 254 | var array = RandomEnumerable.RepeatFloat2(0, 100, 1000).ToArray(); 255 | 256 | float2 sum = default; 257 | for (int n = 0; n < array.Length; n++) sum += array[n]; 258 | var result1 = (float2)sum / array.Length; 259 | var result2 = BurstLinqExtensions.Average(array); 260 | 261 | AssertEx.AreApproximatelyEqual(result1, result2); 262 | } 263 | } 264 | 265 | [Test] 266 | public void Test_Array_Float3() 267 | { 268 | for (int i = 0; i < 1000; i++) 269 | { 270 | var array = RandomEnumerable.RepeatFloat3(0, 100, 1000).ToArray(); 271 | 272 | float3 sum = default; 273 | for (int n = 0; n < array.Length; n++) sum += array[n]; 274 | var result1 = (float3)sum / array.Length; 275 | var result2 = BurstLinqExtensions.Average(array); 276 | 277 | AssertEx.AreApproximatelyEqual(result1, result2); 278 | } 279 | } 280 | 281 | [Test] 282 | public void Test_Array_Float4() 283 | { 284 | for (int i = 0; i < 1000; i++) 285 | { 286 | var array = RandomEnumerable.RepeatFloat4(0, 100, 1000).ToArray(); 287 | 288 | float4 sum = default; 289 | for (int n = 0; n < array.Length; n++) sum += array[n]; 290 | var result1 = (float4)sum / array.Length; 291 | var result2 = BurstLinqExtensions.Average(array); 292 | 293 | AssertEx.AreApproximatelyEqual(result1, result2); 294 | } 295 | } 296 | 297 | [Test] 298 | public void Test_Array_Double2() 299 | { 300 | for (int i = 0; i < 1000; i++) 301 | { 302 | var array = RandomEnumerable.RepeatDouble2(0, 100, 1000).ToArray(); 303 | 304 | double2 sum = default; 305 | for (int n = 0; n < array.Length; n++) sum += array[n]; 306 | var result1 = (double2)sum / array.Length; 307 | var result2 = BurstLinqExtensions.Average(array); 308 | 309 | AssertEx.AreApproximatelyEqual(result1, result2); 310 | } 311 | } 312 | 313 | [Test] 314 | public void Test_Array_Double3() 315 | { 316 | for (int i = 0; i < 1000; i++) 317 | { 318 | var array = RandomEnumerable.RepeatDouble3(0, 100, 1000).ToArray(); 319 | 320 | double3 sum = default; 321 | for (int n = 0; n < array.Length; n++) sum += array[n]; 322 | var result1 = (double3)sum / array.Length; 323 | var result2 = BurstLinqExtensions.Average(array); 324 | 325 | AssertEx.AreApproximatelyEqual(result1, result2); 326 | } 327 | } 328 | 329 | [Test] 330 | public void Test_Array_Double4() 331 | { 332 | for (int i = 0; i < 1000; i++) 333 | { 334 | var array = RandomEnumerable.RepeatDouble4(0, 100, 1000).ToArray(); 335 | 336 | double4 sum = default; 337 | for (int n = 0; n < array.Length; n++) sum += array[n]; 338 | var result1 = (double4)sum / array.Length; 339 | var result2 = BurstLinqExtensions.Average(array); 340 | 341 | AssertEx.AreApproximatelyEqual(result1, result2); 342 | } 343 | } 344 | 345 | } 346 | } -------------------------------------------------------------------------------- /Assets/BurstLinq/Tests/Runtime/SumTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using NUnit.Framework; 4 | using Unity.Mathematics; 5 | using UnityEngine; 6 | using Assert = UnityEngine.Assertions.Assert; 7 | using Random = UnityEngine.Random; 8 | 9 | namespace BurstLinq.Tests 10 | { 11 | public class SumTest 12 | { 13 | [SetUp] 14 | public void SetUp() 15 | { 16 | Random.InitState((int)DateTime.Now.Ticks); 17 | } 18 | 19 | [Test] 20 | public void Test_List() 21 | { 22 | for (int i = 0; i < 1000; i++) 23 | { 24 | var list = RandomEnumerable.RepeatInt(0, 100, 1000).ToList(); 25 | 26 | var result1 = Enumerable.Sum(list); 27 | var result2 = BurstLinqExtensions.Sum(list); 28 | 29 | Assert.AreEqual(result1, result2); 30 | } 31 | } 32 | 33 | [Test] 34 | public void Test_Array_Int() 35 | { 36 | for (int i = 0; i < 1000; i++) 37 | { 38 | var array = RandomEnumerable.RepeatInt(0, 100, 1000).ToArray(); 39 | 40 | var result1 = Enumerable.Sum(array); 41 | var result2 = BurstLinqExtensions.Sum(array); 42 | 43 | Assert.AreEqual(result1, result2); 44 | } 45 | } 46 | 47 | [Test] 48 | public void Test_Array_UInt() 49 | { 50 | for (int i = 0; i < 1000; i++) 51 | { 52 | var array = RandomEnumerable.RepeatUInt(0, 100, 1000).ToArray(); 53 | 54 | uint result1 = default; 55 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 56 | var result2 = BurstLinqExtensions.Sum(array); 57 | 58 | Assert.AreEqual(result1, result2); 59 | } 60 | } 61 | 62 | [Test] 63 | public void Test_Array_Long() 64 | { 65 | for (int i = 0; i < 1000; i++) 66 | { 67 | var array = RandomEnumerable.RepeatLong(0, 100, 1000).ToArray(); 68 | 69 | var result1 = Enumerable.Sum(array); 70 | var result2 = BurstLinqExtensions.Sum(array); 71 | 72 | Assert.AreEqual(result1, result2); 73 | } 74 | } 75 | 76 | [Test] 77 | public void Test_Array_ULong() 78 | { 79 | for (int i = 0; i < 1000; i++) 80 | { 81 | var array = RandomEnumerable.RepeatULong(0, 100, 1000).ToArray(); 82 | 83 | ulong result1 = default; 84 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 85 | var result2 = BurstLinqExtensions.Sum(array); 86 | 87 | Assert.AreEqual(result1, result2); 88 | } 89 | } 90 | 91 | [Test] 92 | public void Test_Array_Float() 93 | { 94 | for (int i = 0; i < 1000; i++) 95 | { 96 | var array = RandomEnumerable.RepeatFloat(0, 100, 1000).ToArray(); 97 | 98 | var result1 = Enumerable.Sum(array); 99 | var result2 = BurstLinqExtensions.Sum(array); 100 | 101 | AssertEx.AreApproximatelyEqual(result1, result2); 102 | } 103 | } 104 | 105 | [Test] 106 | public void Test_Array_Double() 107 | { 108 | for (int i = 0; i < 1000; i++) 109 | { 110 | var array = RandomEnumerable.RepeatDouble(0, 100, 1000).ToArray(); 111 | 112 | var result1 = Enumerable.Sum(array); 113 | var result2 = BurstLinqExtensions.Sum(array); 114 | 115 | AssertEx.AreApproximatelyEqual(result1, result2); 116 | } 117 | } 118 | 119 | [Test] 120 | public void Test_Array_Vector2() 121 | { 122 | for (int i = 0; i < 1000; i++) 123 | { 124 | var array = RandomEnumerable.RepeatVector2(0, 100, 1000).ToArray(); 125 | 126 | Vector2 result1 = default; 127 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 128 | var result2 = BurstLinqExtensions.Sum(array); 129 | 130 | AssertEx.AreApproximatelyEqual(result1, result2); 131 | } 132 | } 133 | 134 | [Test] 135 | public void Test_Array_Vector2Int() 136 | { 137 | for (int i = 0; i < 1000; i++) 138 | { 139 | var array = RandomEnumerable.RepeatVector2Int(0, 100, 1000).ToArray(); 140 | 141 | Vector2Int result1 = default; 142 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 143 | var result2 = BurstLinqExtensions.Sum(array); 144 | 145 | Assert.AreEqual(result1, result2); 146 | } 147 | } 148 | 149 | [Test] 150 | public void Test_Array_Vector3() 151 | { 152 | for (int i = 0; i < 1000; i++) 153 | { 154 | var array = RandomEnumerable.RepeatVector3(0, 100, 1000).ToArray(); 155 | 156 | Vector3 result1 = default; 157 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 158 | var result2 = BurstLinqExtensions.Sum(array); 159 | 160 | AssertEx.AreApproximatelyEqual(result1, result2); 161 | } 162 | } 163 | 164 | [Test] 165 | public void Test_Array_Vector3Int() 166 | { 167 | for (int i = 0; i < 1000; i++) 168 | { 169 | var array = RandomEnumerable.RepeatVector3Int(0, 100, 1000).ToArray(); 170 | 171 | Vector3Int result1 = default; 172 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 173 | var result2 = BurstLinqExtensions.Sum(array); 174 | 175 | Assert.AreEqual(result1, result2); 176 | } 177 | } 178 | 179 | [Test] 180 | public void Test_Array_Vector4() 181 | { 182 | for (int i = 0; i < 1000; i++) 183 | { 184 | var array = RandomEnumerable.RepeatVector4(0, 100, 1000).ToArray(); 185 | 186 | Vector4 result1 = default; 187 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 188 | var result2 = BurstLinqExtensions.Sum(array); 189 | 190 | AssertEx.AreApproximatelyEqual(result1, result2); 191 | } 192 | } 193 | 194 | [Test] 195 | public void Test_Array_Int2() 196 | { 197 | for (int i = 0; i < 1000; i++) 198 | { 199 | var array = RandomEnumerable.RepeatInt2(0, 100, 1000).ToArray(); 200 | 201 | int2 result1 = default; 202 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 203 | var result2 = BurstLinqExtensions.Sum(array); 204 | 205 | Assert.AreEqual(result1, result2); 206 | } 207 | } 208 | 209 | [Test] 210 | public void Test_Array_Int3() 211 | { 212 | for (int i = 0; i < 1000; i++) 213 | { 214 | var array = RandomEnumerable.RepeatInt3(0, 100, 1000).ToArray(); 215 | 216 | int3 result1 = default; 217 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 218 | var result2 = BurstLinqExtensions.Sum(array); 219 | 220 | Assert.AreEqual(result1, result2); 221 | } 222 | } 223 | 224 | [Test] 225 | public void Test_Array_Int4() 226 | { 227 | for (int i = 0; i < 1000; i++) 228 | { 229 | var array = RandomEnumerable.RepeatInt4(0, 100, 1000).ToArray(); 230 | 231 | int4 result1 = default; 232 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 233 | var result2 = BurstLinqExtensions.Sum(array); 234 | 235 | Assert.AreEqual(result1, result2); 236 | } 237 | } 238 | 239 | [Test] 240 | public void Test_Array_UInt2() 241 | { 242 | for (int i = 0; i < 1000; i++) 243 | { 244 | var array = RandomEnumerable.RepeatUInt2(0, 100, 1000).ToArray(); 245 | 246 | uint2 result1 = default; 247 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 248 | var result2 = BurstLinqExtensions.Sum(array); 249 | 250 | Assert.AreEqual(result1, result2); 251 | } 252 | } 253 | 254 | [Test] 255 | public void Test_Array_UInt3() 256 | { 257 | for (int i = 0; i < 1000; i++) 258 | { 259 | var array = RandomEnumerable.RepeatUInt3(0, 100, 1000).ToArray(); 260 | 261 | uint3 result1 = default; 262 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 263 | var result2 = BurstLinqExtensions.Sum(array); 264 | 265 | Assert.AreEqual(result1, result2); 266 | } 267 | } 268 | 269 | [Test] 270 | public void Test_Array_UInt4() 271 | { 272 | for (int i = 0; i < 1000; i++) 273 | { 274 | var array = RandomEnumerable.RepeatUInt4(0, 100, 1000).ToArray(); 275 | 276 | uint4 result1 = default; 277 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 278 | var result2 = BurstLinqExtensions.Sum(array); 279 | 280 | Assert.AreEqual(result1, result2); 281 | } 282 | } 283 | 284 | [Test] 285 | public void Test_Array_Float2() 286 | { 287 | for (int i = 0; i < 1000; i++) 288 | { 289 | var array = RandomEnumerable.RepeatFloat2(0, 100, 1000).ToArray(); 290 | 291 | float2 result1 = default; 292 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 293 | var result2 = BurstLinqExtensions.Sum(array); 294 | 295 | AssertEx.AreApproximatelyEqual(result1, result2); 296 | } 297 | } 298 | 299 | [Test] 300 | public void Test_Array_Float3() 301 | { 302 | for (int i = 0; i < 1000; i++) 303 | { 304 | var array = RandomEnumerable.RepeatFloat3(0, 100, 1000).ToArray(); 305 | 306 | float3 result1 = default; 307 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 308 | var result2 = BurstLinqExtensions.Sum(array); 309 | 310 | AssertEx.AreApproximatelyEqual(result1, result2); 311 | } 312 | } 313 | 314 | [Test] 315 | public void Test_Array_Float4() 316 | { 317 | for (int i = 0; i < 1000; i++) 318 | { 319 | var array = RandomEnumerable.RepeatFloat4(0, 100, 1000).ToArray(); 320 | 321 | float4 result1 = default; 322 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 323 | var result2 = BurstLinqExtensions.Sum(array); 324 | 325 | AssertEx.AreApproximatelyEqual(result1, result2); 326 | } 327 | } 328 | 329 | [Test] 330 | public void Test_Array_Double2() 331 | { 332 | for (int i = 0; i < 1000; i++) 333 | { 334 | var array = RandomEnumerable.RepeatDouble2(0, 100, 1000).ToArray(); 335 | 336 | double2 result1 = default; 337 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 338 | var result2 = BurstLinqExtensions.Sum(array); 339 | 340 | AssertEx.AreApproximatelyEqual(result1, result2); 341 | } 342 | } 343 | 344 | [Test] 345 | public void Test_Array_Double3() 346 | { 347 | for (int i = 0; i < 1000; i++) 348 | { 349 | var array = RandomEnumerable.RepeatDouble3(0, 100, 1000).ToArray(); 350 | 351 | double3 result1 = default; 352 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 353 | var result2 = BurstLinqExtensions.Sum(array); 354 | 355 | AssertEx.AreApproximatelyEqual(result1, result2); 356 | } 357 | } 358 | 359 | [Test] 360 | public void Test_Array_Double4() 361 | { 362 | for (int i = 0; i < 1000; i++) 363 | { 364 | var array = RandomEnumerable.RepeatDouble4(0, 100, 1000).ToArray(); 365 | 366 | double4 result1 = default; 367 | for (int n = 0; n < array.Length; n++) result1 += array[n]; 368 | var result2 = BurstLinqExtensions.Sum(array); 369 | 370 | AssertEx.AreApproximatelyEqual(result1, result2); 371 | } 372 | } 373 | 374 | } 375 | } -------------------------------------------------------------------------------- /Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.burst": { 4 | "version": "1.8.7", 5 | "depth": 1, 6 | "source": "registry", 7 | "dependencies": { 8 | "com.unity.mathematics": "1.2.1" 9 | }, 10 | "url": "https://packages.unity.com" 11 | }, 12 | "com.unity.collab-proxy": { 13 | "version": "2.2.0", 14 | "depth": 0, 15 | "source": "registry", 16 | "dependencies": {}, 17 | "url": "https://packages.unity.com" 18 | }, 19 | "com.unity.collections": { 20 | "version": "2.1.4", 21 | "depth": 0, 22 | "source": "registry", 23 | "dependencies": { 24 | "com.unity.burst": "1.8.4", 25 | "com.unity.modules.unityanalytics": "1.0.0", 26 | "com.unity.nuget.mono-cecil": "1.11.4" 27 | }, 28 | "url": "https://packages.unity.com" 29 | }, 30 | "com.unity.editorcoroutines": { 31 | "version": "1.0.0", 32 | "depth": 1, 33 | "source": "registry", 34 | "dependencies": {}, 35 | "url": "https://packages.unity.com" 36 | }, 37 | "com.unity.ext.nunit": { 38 | "version": "1.0.6", 39 | "depth": 2, 40 | "source": "registry", 41 | "dependencies": {}, 42 | "url": "https://packages.unity.com" 43 | }, 44 | "com.unity.feature.development": { 45 | "version": "1.0.1", 46 | "depth": 0, 47 | "source": "builtin", 48 | "dependencies": { 49 | "com.unity.ide.visualstudio": "2.0.18", 50 | "com.unity.ide.rider": "3.0.24", 51 | "com.unity.ide.vscode": "1.2.5", 52 | "com.unity.editorcoroutines": "1.0.0", 53 | "com.unity.performance.profile-analyzer": "1.2.2", 54 | "com.unity.test-framework": "1.1.33", 55 | "com.unity.testtools.codecoverage": "1.2.4" 56 | } 57 | }, 58 | "com.unity.ide.rider": { 59 | "version": "3.0.24", 60 | "depth": 1, 61 | "source": "registry", 62 | "dependencies": { 63 | "com.unity.ext.nunit": "1.0.6" 64 | }, 65 | "url": "https://packages.unity.com" 66 | }, 67 | "com.unity.ide.visualstudio": { 68 | "version": "2.0.22", 69 | "depth": 0, 70 | "source": "registry", 71 | "dependencies": { 72 | "com.unity.test-framework": "1.1.9" 73 | }, 74 | "url": "https://packages.unity.com" 75 | }, 76 | "com.unity.ide.vscode": { 77 | "version": "1.2.5", 78 | "depth": 1, 79 | "source": "registry", 80 | "dependencies": {}, 81 | "url": "https://packages.unity.com" 82 | }, 83 | "com.unity.mathematics": { 84 | "version": "1.2.6", 85 | "depth": 2, 86 | "source": "registry", 87 | "dependencies": {}, 88 | "url": "https://packages.unity.com" 89 | }, 90 | "com.unity.nuget.mono-cecil": { 91 | "version": "1.11.4", 92 | "depth": 1, 93 | "source": "registry", 94 | "dependencies": {}, 95 | "url": "https://packages.unity.com" 96 | }, 97 | "com.unity.performance.profile-analyzer": { 98 | "version": "1.2.2", 99 | "depth": 1, 100 | "source": "registry", 101 | "dependencies": {}, 102 | "url": "https://packages.unity.com" 103 | }, 104 | "com.unity.settings-manager": { 105 | "version": "2.0.1", 106 | "depth": 2, 107 | "source": "registry", 108 | "dependencies": {}, 109 | "url": "https://packages.unity.com" 110 | }, 111 | "com.unity.sysroot": { 112 | "version": "2.0.7", 113 | "depth": 1, 114 | "source": "registry", 115 | "dependencies": {}, 116 | "url": "https://packages.unity.com" 117 | }, 118 | "com.unity.sysroot.linux-x86_64": { 119 | "version": "2.0.6", 120 | "depth": 1, 121 | "source": "registry", 122 | "dependencies": { 123 | "com.unity.sysroot": "2.0.7" 124 | }, 125 | "url": "https://packages.unity.com" 126 | }, 127 | "com.unity.test-framework": { 128 | "version": "1.1.33", 129 | "depth": 1, 130 | "source": "registry", 131 | "dependencies": { 132 | "com.unity.ext.nunit": "1.0.6", 133 | "com.unity.modules.imgui": "1.0.0", 134 | "com.unity.modules.jsonserialize": "1.0.0" 135 | }, 136 | "url": "https://packages.unity.com" 137 | }, 138 | "com.unity.test-framework.performance": { 139 | "version": "3.0.3", 140 | "depth": 0, 141 | "source": "registry", 142 | "dependencies": { 143 | "com.unity.test-framework": "1.1.31", 144 | "com.unity.modules.jsonserialize": "1.0.0" 145 | }, 146 | "url": "https://packages.unity.com" 147 | }, 148 | "com.unity.testtools.codecoverage": { 149 | "version": "1.2.4", 150 | "depth": 1, 151 | "source": "registry", 152 | "dependencies": { 153 | "com.unity.test-framework": "1.0.16", 154 | "com.unity.settings-manager": "1.0.1" 155 | }, 156 | "url": "https://packages.unity.com" 157 | }, 158 | "com.unity.textmeshpro": { 159 | "version": "3.0.6", 160 | "depth": 0, 161 | "source": "registry", 162 | "dependencies": { 163 | "com.unity.ugui": "1.0.0" 164 | }, 165 | "url": "https://packages.unity.com" 166 | }, 167 | "com.unity.timeline": { 168 | "version": "1.7.5", 169 | "depth": 0, 170 | "source": "registry", 171 | "dependencies": { 172 | "com.unity.modules.director": "1.0.0", 173 | "com.unity.modules.animation": "1.0.0", 174 | "com.unity.modules.audio": "1.0.0", 175 | "com.unity.modules.particlesystem": "1.0.0" 176 | }, 177 | "url": "https://packages.unity.com" 178 | }, 179 | "com.unity.toolchain.macos-arm64-linux-x86_64": { 180 | "version": "2.0.0", 181 | "depth": 0, 182 | "source": "registry", 183 | "dependencies": { 184 | "com.unity.sysroot": "2.0.7", 185 | "com.unity.sysroot.linux-x86_64": "2.0.6" 186 | }, 187 | "url": "https://packages.unity.com" 188 | }, 189 | "com.unity.ugui": { 190 | "version": "1.0.0", 191 | "depth": 0, 192 | "source": "builtin", 193 | "dependencies": { 194 | "com.unity.modules.ui": "1.0.0", 195 | "com.unity.modules.imgui": "1.0.0" 196 | } 197 | }, 198 | "com.unity.visualscripting": { 199 | "version": "1.8.0", 200 | "depth": 0, 201 | "source": "registry", 202 | "dependencies": { 203 | "com.unity.ugui": "1.0.0", 204 | "com.unity.modules.jsonserialize": "1.0.0" 205 | }, 206 | "url": "https://packages.unity.com" 207 | }, 208 | "com.unity.modules.ai": { 209 | "version": "1.0.0", 210 | "depth": 0, 211 | "source": "builtin", 212 | "dependencies": {} 213 | }, 214 | "com.unity.modules.androidjni": { 215 | "version": "1.0.0", 216 | "depth": 0, 217 | "source": "builtin", 218 | "dependencies": {} 219 | }, 220 | "com.unity.modules.animation": { 221 | "version": "1.0.0", 222 | "depth": 0, 223 | "source": "builtin", 224 | "dependencies": {} 225 | }, 226 | "com.unity.modules.assetbundle": { 227 | "version": "1.0.0", 228 | "depth": 0, 229 | "source": "builtin", 230 | "dependencies": {} 231 | }, 232 | "com.unity.modules.audio": { 233 | "version": "1.0.0", 234 | "depth": 0, 235 | "source": "builtin", 236 | "dependencies": {} 237 | }, 238 | "com.unity.modules.cloth": { 239 | "version": "1.0.0", 240 | "depth": 0, 241 | "source": "builtin", 242 | "dependencies": { 243 | "com.unity.modules.physics": "1.0.0" 244 | } 245 | }, 246 | "com.unity.modules.director": { 247 | "version": "1.0.0", 248 | "depth": 0, 249 | "source": "builtin", 250 | "dependencies": { 251 | "com.unity.modules.audio": "1.0.0", 252 | "com.unity.modules.animation": "1.0.0" 253 | } 254 | }, 255 | "com.unity.modules.imageconversion": { 256 | "version": "1.0.0", 257 | "depth": 0, 258 | "source": "builtin", 259 | "dependencies": {} 260 | }, 261 | "com.unity.modules.imgui": { 262 | "version": "1.0.0", 263 | "depth": 0, 264 | "source": "builtin", 265 | "dependencies": {} 266 | }, 267 | "com.unity.modules.jsonserialize": { 268 | "version": "1.0.0", 269 | "depth": 0, 270 | "source": "builtin", 271 | "dependencies": {} 272 | }, 273 | "com.unity.modules.particlesystem": { 274 | "version": "1.0.0", 275 | "depth": 0, 276 | "source": "builtin", 277 | "dependencies": {} 278 | }, 279 | "com.unity.modules.physics": { 280 | "version": "1.0.0", 281 | "depth": 0, 282 | "source": "builtin", 283 | "dependencies": {} 284 | }, 285 | "com.unity.modules.physics2d": { 286 | "version": "1.0.0", 287 | "depth": 0, 288 | "source": "builtin", 289 | "dependencies": {} 290 | }, 291 | "com.unity.modules.screencapture": { 292 | "version": "1.0.0", 293 | "depth": 0, 294 | "source": "builtin", 295 | "dependencies": { 296 | "com.unity.modules.imageconversion": "1.0.0" 297 | } 298 | }, 299 | "com.unity.modules.subsystems": { 300 | "version": "1.0.0", 301 | "depth": 1, 302 | "source": "builtin", 303 | "dependencies": { 304 | "com.unity.modules.jsonserialize": "1.0.0" 305 | } 306 | }, 307 | "com.unity.modules.terrain": { 308 | "version": "1.0.0", 309 | "depth": 0, 310 | "source": "builtin", 311 | "dependencies": {} 312 | }, 313 | "com.unity.modules.terrainphysics": { 314 | "version": "1.0.0", 315 | "depth": 0, 316 | "source": "builtin", 317 | "dependencies": { 318 | "com.unity.modules.physics": "1.0.0", 319 | "com.unity.modules.terrain": "1.0.0" 320 | } 321 | }, 322 | "com.unity.modules.tilemap": { 323 | "version": "1.0.0", 324 | "depth": 0, 325 | "source": "builtin", 326 | "dependencies": { 327 | "com.unity.modules.physics2d": "1.0.0" 328 | } 329 | }, 330 | "com.unity.modules.ui": { 331 | "version": "1.0.0", 332 | "depth": 0, 333 | "source": "builtin", 334 | "dependencies": {} 335 | }, 336 | "com.unity.modules.uielements": { 337 | "version": "1.0.0", 338 | "depth": 0, 339 | "source": "builtin", 340 | "dependencies": { 341 | "com.unity.modules.ui": "1.0.0", 342 | "com.unity.modules.imgui": "1.0.0", 343 | "com.unity.modules.jsonserialize": "1.0.0" 344 | } 345 | }, 346 | "com.unity.modules.umbra": { 347 | "version": "1.0.0", 348 | "depth": 0, 349 | "source": "builtin", 350 | "dependencies": {} 351 | }, 352 | "com.unity.modules.unityanalytics": { 353 | "version": "1.0.0", 354 | "depth": 0, 355 | "source": "builtin", 356 | "dependencies": { 357 | "com.unity.modules.unitywebrequest": "1.0.0", 358 | "com.unity.modules.jsonserialize": "1.0.0" 359 | } 360 | }, 361 | "com.unity.modules.unitywebrequest": { 362 | "version": "1.0.0", 363 | "depth": 0, 364 | "source": "builtin", 365 | "dependencies": {} 366 | }, 367 | "com.unity.modules.unitywebrequestassetbundle": { 368 | "version": "1.0.0", 369 | "depth": 0, 370 | "source": "builtin", 371 | "dependencies": { 372 | "com.unity.modules.assetbundle": "1.0.0", 373 | "com.unity.modules.unitywebrequest": "1.0.0" 374 | } 375 | }, 376 | "com.unity.modules.unitywebrequestaudio": { 377 | "version": "1.0.0", 378 | "depth": 0, 379 | "source": "builtin", 380 | "dependencies": { 381 | "com.unity.modules.unitywebrequest": "1.0.0", 382 | "com.unity.modules.audio": "1.0.0" 383 | } 384 | }, 385 | "com.unity.modules.unitywebrequesttexture": { 386 | "version": "1.0.0", 387 | "depth": 0, 388 | "source": "builtin", 389 | "dependencies": { 390 | "com.unity.modules.unitywebrequest": "1.0.0", 391 | "com.unity.modules.imageconversion": "1.0.0" 392 | } 393 | }, 394 | "com.unity.modules.unitywebrequestwww": { 395 | "version": "1.0.0", 396 | "depth": 0, 397 | "source": "builtin", 398 | "dependencies": { 399 | "com.unity.modules.unitywebrequest": "1.0.0", 400 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 401 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 402 | "com.unity.modules.audio": "1.0.0", 403 | "com.unity.modules.assetbundle": "1.0.0", 404 | "com.unity.modules.imageconversion": "1.0.0" 405 | } 406 | }, 407 | "com.unity.modules.vehicles": { 408 | "version": "1.0.0", 409 | "depth": 0, 410 | "source": "builtin", 411 | "dependencies": { 412 | "com.unity.modules.physics": "1.0.0" 413 | } 414 | }, 415 | "com.unity.modules.video": { 416 | "version": "1.0.0", 417 | "depth": 0, 418 | "source": "builtin", 419 | "dependencies": { 420 | "com.unity.modules.audio": "1.0.0", 421 | "com.unity.modules.ui": "1.0.0", 422 | "com.unity.modules.unitywebrequest": "1.0.0" 423 | } 424 | }, 425 | "com.unity.modules.vr": { 426 | "version": "1.0.0", 427 | "depth": 0, 428 | "source": "builtin", 429 | "dependencies": { 430 | "com.unity.modules.jsonserialize": "1.0.0", 431 | "com.unity.modules.physics": "1.0.0", 432 | "com.unity.modules.xr": "1.0.0" 433 | } 434 | }, 435 | "com.unity.modules.wind": { 436 | "version": "1.0.0", 437 | "depth": 0, 438 | "source": "builtin", 439 | "dependencies": {} 440 | }, 441 | "com.unity.modules.xr": { 442 | "version": "1.0.0", 443 | "depth": 0, 444 | "source": "builtin", 445 | "dependencies": { 446 | "com.unity.modules.physics": "1.0.0", 447 | "com.unity.modules.jsonserialize": "1.0.0", 448 | "com.unity.modules.subsystems": "1.0.0" 449 | } 450 | } 451 | } 452 | } 453 | --------------------------------------------------------------------------------