Testing some singleton implementations

Dmitry Olshansky dmitry.olsh at gmail.com
Fri Jan 31 01:58:06 PST 2014


31-Jan-2014 12:25, Andrej Mitrovic пишет:
> There was a nice blog-post about implementing low-lock singletons in D, here:
> http://davesdprogramming.wordpress.com/2013/05/06/low-lock-singletons/
>
> One suggestion on Reddit was by dawgfoto (I think this is Martin
> Nowak?), to use atomic primitives instead:
> http://www.reddit.com/r/programming/comments/1droaa/lowlock_singletons_in_d_the_singleton_pattern/c9tmz07
>
> I wanted to benchmark these different approaches. I was expecting
> Martin's implementation to be the fastest one, but on my machine
> (Athlon II X4 620 - 2.61GHz) the implementation in the blog post turns
> out to be the fastest one.

And it was a big thing because of that. Also keep in mind that atomic 
ops are _relatively_ cheap on x86 the stuff should get even better on 
say ARM.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list