301089 improved tests

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1271 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-02-16 22:15:37 +00:00
parent b616fc1e3a
commit d54c92bf3e
2 changed files with 18 additions and 17 deletions

View File

@ -50,9 +50,16 @@ public class CounterStatistic
*/
public void add(final long delta)
{
updateMax(_curr.addAndGet(delta));
long value=_curr.addAndGet(delta);
if (delta > 0)
_total.addAndGet(delta);
long oldValue = _max.get();
while (value > oldValue)
{
if (_max.compareAndSet(oldValue, value))
break;
oldValue = _max.get();
}
}
/* ------------------------------------------------------------ */
@ -108,14 +115,7 @@ public class CounterStatistic
}
/* ------------------------------------------------------------ */
protected void updateMax(long value)
protected void upxdateMax(long value)
{
long oldValue = _max.get();
while (value > oldValue)
{
if (_max.compareAndSet(oldValue, value))
break;
oldValue = _max.get();
}
}
}

View File

@ -51,14 +51,6 @@ public class SampleStatistic
public void set(final long sample)
{
long oldMax = _max.get();
while (sample > oldMax)
{
if (_max.compareAndSet(oldMax, sample))
break;
oldMax = _max.get();
}
long total = _total.addAndGet(sample);
long count = _count.incrementAndGet();
@ -68,6 +60,15 @@ public class SampleStatistic
long delta10 = sample*10 - mean10;
_totalVariance100.addAndGet(delta10*delta10);
}
long oldMax = _max.get();
while (sample > oldMax)
{
if (_max.compareAndSet(oldMax, sample))
break;
oldMax = _max.get();
}
}
/* ------------------------------------------------------------ */