Testing some singleton implementations

Stanislav Blinov stanislav.blinov at gmail.com
Fri Jan 31 03:42:09 PST 2014


On Friday, 31 January 2014 at 11:18:03 UTC, Andrej Mitrovic wrote:
> On 1/31/14, Stanislav Blinov <stanislav.blinov at gmail.com> wrote:
>> First, subsequent runs on my machine show interleaving results.
>> It also seems that either there *is* a race in there somewhere,
>> or maybe a bug?.. Some runs just flat freeze (even on small
>> thread counts) :\
>
> Hmm.. Well I know we've had some issues with threads on 
> FreeBSD. It's
> hard to just guess what's wrong though. :)

I'm not comfortable with that atomicOp in the thread function.

I've reworked the unittest a little, to accomodate for multiple 
runs:

http://codepad.org/ghZdjvUE

And here are ldc's results (you may want to lower the thread 
count for dmd, I've killed program after the very first test took 
27 second :o):

Test 0 time for SyncSingleton: 35.4775 msecs.
Test 0 time for AtomicSingleton: 58.5859 msecs.

Test 1 time for SyncSingleton: 64.9863 msecs.
Test 1 time for AtomicSingleton: 12.5479 msecs.

Test 2 time for SyncSingleton: 44.2617 msecs.
Test 2 time for AtomicSingleton: 26.2842 msecs.

Test 3 time for SyncSingleton: 24.8008 msecs.
Test 3 time for AtomicSingleton: 34.416 msecs.

Test 4 time for SyncSingleton: 5.63477 msecs.
Test 4 time for AtomicSingleton: 28.458 msecs.

Test 5 time for SyncSingleton: 18.1123 msecs.
Test 5 time for AtomicSingleton: 29.6738 msecs.

Test 6 time for SyncSingleton: 12.0234 msecs.
Test 6 time for AtomicSingleton: 53.2061 msecs.

Test 7 time for SyncSingleton: 70.6982 msecs.
Test 7 time for AtomicSingleton: 13.2285 msecs.

Test 8 time for SyncSingleton: 12.3447 msecs.
Test 8 time for AtomicSingleton: 8.06348 msecs.

Test 9 time for SyncSingleton: 20.3145 msecs.
Test 9 time for AtomicSingleton: 14.334 msecs.

Again, inconclusive :)


More information about the Digitalmars-d mailing list