Re: Speed of synchronized

2016-10-18 Thread Christian Köstlin via Digitalmars-d-learn
On 18/10/16 07:04, Daniel Kozak via Digitalmars-d-learn wrote: > dub run --build=release --compiler=ldc on my machine i get the following output (using ldc2) ldc2 --version 09:32 LDC - the LLVM D compiler (1.0.0): based on DMD v2.070.2 and LLVM 3.8.1 built with LDC - the LLVM D compiler

Re: Speed of synchronized

2016-10-17 Thread Daniel Kozak via Digitalmars-d-learn
Dne 17.10.2016 v 23:40 Christian Köstlin via Digitalmars-d-learn napsal(a): Could someone check the numbers on another OS-X machine? Unfortunately I only have one available. Thanks in advance! Can you try it on OSX with ldc compiler: dub run --build=release --compiler=ldc

Re: Speed of synchronized

2016-10-17 Thread Christian Köstlin via Digitalmars-d-learn
On 17/10/16 14:44, Christian Köstlin wrote: > On 17/10/16 14:09, Daniel Kozak via Digitalmars-d-learn wrote: >> Dne 16.10.2016 v 10:41 Christian Köstlin via Digitalmars-d-learn napsal(a): >>> Hi, >>> >>> for an exercise I had to implement a thread safe counter. >>> This is what I came up with: >>>

Re: Speed of synchronized

2016-10-17 Thread Christian Köstlin via Digitalmars-d-learn
On 17/10/16 14:09, Daniel Kozak via Digitalmars-d-learn wrote: > Dne 16.10.2016 v 10:41 Christian Köstlin via Digitalmars-d-learn napsal(a): >> Hi, >> >> for an exercise I had to implement a thread safe counter. >> This is what I came up with: >> >> >> btw. I run the code with dub run

Re: Speed of synchronized

2016-10-17 Thread Daniel Kozak via Digitalmars-d-learn
Dne 16.10.2016 v 10:41 Christian Köstlin via Digitalmars-d-learn napsal(a): Hi, for an exercise I had to implement a thread safe counter. This is what I came up with: btw. I run the code with dub run --build=release Thanks in advance, Christian So I have done some testing, on my pc:

Re: Speed of synchronized

2016-10-17 Thread Daniel Kozak via Digitalmars-d-learn
On Monday, 17 October 2016 at 06:38:08 UTC, Daniel Kozak wrote: Dne 17.10.2016 v 07:55 Christian Köstlin via Digitalmars-d-learn napsal(a): [...] I am still unable to get your java code working: [kozak@dajinka threads]$ ./gradlew clean build :clean :compileJava :processResources UP-TO-DATE

Re: Speed of synchronized

2016-10-17 Thread Daniel Kozak via Digitalmars-d-learn
Dne 17.10.2016 v 07:55 Christian Köstlin via Digitalmars-d-learn napsal(a): to run java call ./gradlew clean build -> counter.AtomicIntCounter@25992ae3 expected: 200 got: 100 in: 22ms counter.AtomicLongCounter@2539f946 expected: 200 got: 100 in: 17ms

Re: Speed of synchronized

2016-10-17 Thread Christian Köstlin via Digitalmars-d-learn
On 17/10/16 06:55, Daniel Kozak via Digitalmars-d-learn wrote: > Dne 16.10.2016 v 10:41 Christian Köstlin via Digitalmars-d-learn napsal(a): > >> My question now is, why is each mutex based thread safe variant so slow >> compared to a similar java program? The only hint could be something >>

Re: Speed of synchronized

2016-10-17 Thread Christian Köstlin via Digitalmars-d-learn
On 16/10/16 19:50, tcak wrote: > On Sunday, 16 October 2016 at 08:41:26 UTC, Christian Köstlin wrote: >> Hi, >> >> for an exercise I had to implement a thread safe counter. This is what >> I came up with: >> >> [...] > > Could you try that: > > class ThreadSafe3Counter: Counter{ > private long

Re: Speed of synchronized

2016-10-16 Thread Daniel Kozak via Digitalmars-d-learn
Dne 16.10.2016 v 10:41 Christian Köstlin via Digitalmars-d-learn napsal(a): My question now is, why is each mutex based thread safe variant so slow compared to a similar java program? The only hint could be something like:

Re: Speed of synchronized

2016-10-16 Thread tcak via Digitalmars-d-learn
On Sunday, 16 October 2016 at 08:41:26 UTC, Christian Köstlin wrote: Hi, for an exercise I had to implement a thread safe counter. This is what I came up with: [...] Could you try that: class ThreadSafe3Counter: Counter{ private long counter; private core.sync.mutex.Mutex mtx;