Skip to content

Commit 20c8762

Browse files
authored
Update README.md
1 parent ae2799b commit 20c8762

File tree

1 file changed

+71
-1
lines changed

1 file changed

+71
-1
lines changed

README.md

+71-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Object Pooling for Unity
33

44
## Features
5-
- Faster in terms of performance than Instantiate/Destroy
5+
- Faster in terms of performance than Instantiate/Destroy (Test at the end of README)
66
- Easy to use
77
- Easy to integrate with already written spawn systems
88
- Callbacks OnSpawn & OnDespawn for resseting after object being used
@@ -93,3 +93,73 @@ public class Health : MonoBehaviour, IPoolable
9393
public void OnDespawn() { }
9494
}
9595
```
96+
97+
### Peformance test:
98+
Creating and destroying 1000 objects.
99+
100+
#### Instantiate/Destroy:
101+
102+
```csharp
103+
using Sirenix.OdinInspector;
104+
using System.Diagnostics;
105+
using UnityEngine;
106+
107+
public class Tester : MonoBehaviour
108+
{
109+
[SerializeField] private GameObject _object = null;
110+
111+
[Button]
112+
private void Test()
113+
{
114+
Stopwatch stopwatch = new Stopwatch();
115+
stopwatch.Start();
116+
117+
for (int i = 0; i < 1000; i++)
118+
{
119+
var instance = Instantiate(_object);
120+
Destroy(instance);
121+
}
122+
123+
stopwatch.Stop();
124+
print($"Milliseconds: {stopwatch.ElapsedMilliseconds}");
125+
}
126+
}
127+
```
128+
##### Result: [16:26:15] Milliseconds: 6
129+
130+
#### Spawn/Despawn:
131+
132+
```csharp
133+
using Sirenix.OdinInspector;
134+
using System.Diagnostics;
135+
using ToolBox.Pools;
136+
using UnityEngine;
137+
138+
public class Tester : MonoBehaviour
139+
{
140+
[SerializeField] private GameObject _object = null;
141+
142+
private void Awake()
143+
{
144+
_object.Populate(1000);
145+
}
146+
147+
[Button]
148+
private void Test()
149+
{
150+
Stopwatch stopwatch = new Stopwatch();
151+
stopwatch.Start();
152+
153+
for (int i = 0; i < 1000; i++)
154+
{
155+
var instance = _object.Spawn();
156+
instance.Despawn();
157+
}
158+
159+
stopwatch.Stop();
160+
print($"Milliseconds: {stopwatch.ElapsedMilliseconds}");
161+
}
162+
}
163+
164+
```
165+
##### Result: [16:29:36] Milliseconds: 2

0 commit comments

Comments
 (0)