Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: VERY PECULIAR PROBLEM Date: Fri, 13 Mar 2015 21:40:28 +0100 Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net qXpDsXkjGnu1RsUWUPBlvgGWeq8q9N+xZ57n/5ZCcYCZhwBYc= Cancel-Lock: sha1:S1kMj/d0U9oSFEhugDSVKkWNoaE= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:31320 On 13.03.2015 11:12, Robbie Brown wrote: > On 13/03/15 09:36, Nigel Wade wrote: >> My guess, and it has to be a guess because of the total lack of >> information as others have highlighted, is that your code (the *other* >> code, which you don't show) "doesn't count time" because it's running in >> another thread which isn't synchronized properly. The code you've shown >> is a tight, CPU bound, loop so I guess the other thread is starved of >> CPU cycles. Add your System.out and the tight loop becomes I/O bound, >> allowing the other thread to gain CPU cycles. >> >> All complete conjecture based on a complete lack of information. > > This sounds highly plausible. CPU starvation is not so likely on modern hardware and OS. I think it more plausible that, since writing to the stream is missing (which is synchronized!), there is no memory barrier and updates on non volatile variables in the measurement thread are not visible to whatever other thread tries to get at the timing measurement. > OP why don't you paste-bin your code and let the boffins (and us that > are less than perfect) have a look. Amen. There is really far too little information. Cheer robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/