Skip to content

Commit 6a20e66

Browse files
authored
Update README.md
1 parent 65c9299 commit 6a20e66

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ This package allows you to Tag your Game Objects with ScriptableObjects.
1313
![](https://imgur.com/EPxkbza.png)
1414

1515
### Runtime Operations:
16+
<details><summary>Code</summary>
17+
<p>
18+
1619
```csharp
1720
public class Test : MonoBehaviour
1821
{
@@ -41,4 +44,110 @@ public class Test : MonoBehaviour
4144
_enemy.RemoveTag(_zombieTag);
4245
}
4346
}
47+
```
48+
49+
</p>
50+
</details>
51+
52+
53+
### Performance Test:
54+
<details><summary>Code</summary>
55+
<p>
56+
57+
```csharp
58+
using Sirenix.OdinInspector;
59+
using System.Diagnostics;
60+
using ToolBox.Pools;
61+
using ToolBox.Tags;
62+
using UnityEngine;
63+
64+
namespace ToolBox.Test
65+
{
66+
[DefaultExecutionOrder(-100)]
67+
public class Tester : MonoBehaviour
68+
{
69+
[SerializeField] private Tag _myTag = null;
70+
[SerializeField] private string _unityTag = null;
71+
[SerializeField] private GameObject _object = null;
72+
73+
[SerializeField, ReadOnly] private float _myMS = 0;
74+
[SerializeField, ReadOnly] private float _unityMS = 0;
75+
76+
[SerializeField, ReadOnly] private bool _hasMyTag = false;
77+
[SerializeField, ReadOnly] private bool _hasUnityTag = false;
78+
79+
private const int ITERATIONS = 10;
80+
81+
[Button]
82+
private void MyTagTest()
83+
{
84+
_myMS = 0f;
85+
86+
for (int i = 0; i < ITERATIONS; i++)
87+
{
88+
Stopwatch stopwatch = new Stopwatch();
89+
stopwatch.Start();
90+
91+
for (int j = 0; j < 100000; j++)
92+
{
93+
_hasMyTag = _object.HasTag(_myTag);
94+
}
95+
96+
stopwatch.Stop();
97+
_myMS += stopwatch.ElapsedMilliseconds;
98+
}
99+
100+
_myMS /= ITERATIONS;
101+
}
102+
103+
[Button]
104+
private void UnityTagTest()
105+
{
106+
_unityMS = 0;
107+
108+
for (int i = 0; i < ITERATIONS; i++)
109+
{
110+
Stopwatch stopwatch = new Stopwatch();
111+
stopwatch.Start();
112+
113+
for (int j = 0; j < 100000; j++)
114+
{
115+
_hasUnityTag = _object.CompareTag(_unityTag);
116+
}
117+
118+
stopwatch.Stop();
119+
_unityMS += stopwatch.ElapsedMilliseconds;
120+
}
121+
122+
_unityMS /= ITERATIONS;
123+
}
124+
}
125+
}
126+
44127
```
128+
</p>
129+
</details>
130+
131+
<details><summary>Scene and Objects Setup</summary>
132+
<p>
133+
134+
![Scene Setup](https://imgur.com/IgSjjpz.png)
135+
136+
![A Object Setup](https://imgur.com/0kkITFa.png)
137+
138+
![B Object Setup](https://imgur.com/4DVS3XP.png)
139+
</p>
140+
</details>
141+
142+
<details><summary>Test Result</summary>
143+
<p>
144+
145+
![Result](https://imgur.com/YedN04E.png)
146+
147+
</p>
148+
</details>
149+
150+
151+
152+
153+

0 commit comments

Comments
 (0)