public static void NoPool(Int32 numberIterations) { for (int i = 0; i < numberIterations; ++i) { ExpensiveObject eo = new ExpensiveObject(); } }
public static void Pool(Int32 numberIterations) { ObjectPool op = new ObjectPool(typeof(ExpensiveObject), 10, 2); for (int i = 0; i < numberIterations; ++i) { ExpensiveObject eo = (ExpensiveObject)op.GetObject(); //use eo.Reset(); op.ReturnObject(eo); } }