-- Ed Lazor <[email protected]> wrote (on Tuesday, 21 July 2009, 11:03 AM -0700): > On Tue, Jul 21, 2009 at 10:48 AM, troels knak-nielsen<[email protected]> > wrote: > > Irey<[email protected]> wrote: > >> That's a performance boost of 7X using a singleton versus not using a > >> singleton. > > > > You're conflating two unrelated concepts. The performance difference > > that you observe is due to the difference between instantiating a new > > object per iteration vs. reusing the same. > > Isn't that one of the benefits of using a singleton?
No, that's a performance benefit of re-using the same object. You can achieve the same benefit by passing the object in as a dependency to another object. > > You can reuse the same object in other ways than through a global symbol. > > Aren't singleton classes preferred over global variables? Yes, but only slightly. A singleton is still a global container of sorts. The main difference is that it's namespaced. -- Matthew Weier O'Phinney Project Lead | [email protected] Zend Framework | http://framework.zend.com/
