Skip to content

Instantly share code, notes, and snippets.

@AndySum
Created January 3, 2017 05:53
Show Gist options
  • Save AndySum/d0d3f11e4c24ad6ed083a605e6f2fa47 to your computer and use it in GitHub Desktop.
Save AndySum/d0d3f11e4c24ad6ed083a605e6f2fa47 to your computer and use it in GitHub Desktop.
Pool benchmarking for Unity Asset Store
using UnityEngine;
using System.Collections;
using PathologicalGames;
public class PoolTest : MonoBehaviour {
[SerializeField] SpawnPool pathpool;
[SerializeField] GameObject sourcePrefab;
int spawnno = 5000;
System.Diagnostics.Stopwatch sw;
//Test one then the other, swapping order makes no difference in performance.
void DoIt () {
long testA, testB;
sw = new System.Diagnostics.Stopwatch();
//Pathological Poolmanager
//https://www.assetstore.unity3d.com/en/#!/content/1010
sw.Reset();
sw.Start();
for (int i = 0; i < spawnno; i++)
{
//pathpool.Spawn("CubeTest");
pathpool.Spawn(sourcePrefab);
}
sw.Stop();
testA = sw.ElapsedMilliseconds;
Debug.Log("Pathological PoolManager: " + testA + " ms");
pathpool.DespawnAll();
//-----------------------------------------
//Fast Pool
//https://www.assetstore.unity3d.com/en/#!/content/38709
sw.Reset();
sw.Start();
//Patho
for (int i = 0; i < spawnno; i++)
{
FastPoolManager.GetPool(sourcePrefab, true).FastInstantiate();
}
sw.Stop();
testB = sw.ElapsedMilliseconds;
Debug.Log("Fastpool: " + testB + " ms");
}
bool done = false;
//run it after one second to take away any "startup" effects.
void Update () {
if (!done && Time.time > 1.0f)
{
DoIt();
done = true;
}
}
//My results
//CPU: i7 6950x
/*
5000 objects, both 5000 objects preloaded
PoolManager (Pathological) : 47 ms
Fast Pool (Watermelon Assets): 36 ms
5000 objects, both 2000 objects preloaded
PoolManager (Pathological) : 183 ms
Fast Pool (Watermelon Assets): 99 ms
5000 objects, both 0 objects preloaded
PoolManager (Pathological) : 260 ms
Fast Pool (Watermelon Assets): 140 ms
*/
}
@AndySum
Copy link
Author

AndySum commented Jan 3, 2017

//My results
//CPU: i7 6950x
/*
	5000 objects, both 5000 objects preloaded
	PoolManager (Pathological)   : 47 ms
	Fast Pool (Watermelon Assets): 36 ms
	5000 objects, both 2000 objects preloaded
	PoolManager (Pathological)   : 183 ms
	Fast Pool (Watermelon Assets): 99 ms
	5000 objects, both 0 objects preloaded
	PoolManager (Pathological)   : 260 ms
	Fast Pool (Watermelon Assets): 140 ms
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment