@@ -62,7 +62,6 @@ Tags Container allows you to group tags in a single asset, which allows you to c
6262``` csharp
6363using Sirenix .OdinInspector ;
6464using System .Diagnostics ;
65- using ToolBox .Pools ;
6665using ToolBox .Tags ;
6766using UnityEngine ;
6867
@@ -75,56 +74,36 @@ namespace ToolBox.Test
7574 [SerializeField ] private string _unityTag = null ;
7675 [SerializeField ] private GameObject _object = null ;
7776
78- [SerializeField , ReadOnly ] private float _myMS = 0 ;
79- [SerializeField , ReadOnly ] private float _unityMS = 0 ;
80-
81- [SerializeField , ReadOnly ] private bool _hasMyTag = false ;
82- [SerializeField , ReadOnly ] private bool _hasUnityTag = false ;
83-
84- private const int ITERATIONS = 10 ;
77+ private const int ITERATIONS = 100000 ;
8578
8679 [Button ]
8780 private void MyTagTest ()
8881 {
89- _myMS = 0 f ;
82+ Stopwatch stopwatch = new Stopwatch ();
83+ stopwatch .Start ();
9084
91- for (int i = 0 ; i < ITERATIONS ; i ++ )
85+ for (int j = 0 ; j < ITERATIONS ; j ++ )
9286 {
93- Stopwatch stopwatch = new Stopwatch ();
94- stopwatch .Start ();
95-
96- for (int j = 0 ; j < 100000 ; j ++ )
97- {
98- _hasMyTag = _object .HasTag (_myTag );
99- }
100-
101- stopwatch .Stop ();
102- _myMS += stopwatch .ElapsedMilliseconds ;
87+ _object .HasTag (_myTag );
10388 }
10489
105- _myMS /= ITERATIONS ;
90+ stopwatch .Stop ();
91+ UnityEngine .Debug .Log ($" Scriptable Object Tag Comparer: {stopwatch .ElapsedMilliseconds } milliseconds" );
10692 }
10793
10894 [Button ]
10995 private void UnityTagTest ()
11096 {
111- _unityMS = 0 ;
97+ Stopwatch stopwatch = new Stopwatch ();
98+ stopwatch .Start ();
11299
113- for (int i = 0 ; i < ITERATIONS ; i ++ )
100+ for (int j = 0 ; j < ITERATIONS ; j ++ )
114101 {
115- Stopwatch stopwatch = new Stopwatch ();
116- stopwatch .Start ();
117-
118- for (int j = 0 ; j < 100000 ; j ++ )
119- {
120- _hasUnityTag = _object .CompareTag (_unityTag );
121- }
122-
123- stopwatch .Stop ();
124- _unityMS += stopwatch .ElapsedMilliseconds ;
102+ _object .CompareTag (_unityTag );
125103 }
126104
127- _unityMS /= ITERATIONS ;
105+ stopwatch .Stop ();
106+ UnityEngine .Debug .Log ($" Unity Tag Comparer: {stopwatch .ElapsedMilliseconds } milliseconds" );
128107 }
129108 }
130109}
@@ -147,7 +126,7 @@ namespace ToolBox.Test
147126<details ><summary >Test Result</summary >
148127<p >
149128
150- ![ Result] ( https://imgur.com/YedN04E .png )
129+ ![ Result] ( https://imgur.com/c8rnKdo .png )
151130
152131</p >
153132</details >
0 commit comments