1 |
|
/* |
2 |
|
* Written by Doug Lea and released to the public domain, as explained at |
3 |
< |
* http://creativecommons.org/licenses/publicdomain |
3 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
4 |
|
*/ |
5 |
|
|
6 |
|
/* |
27 |
|
*/ |
28 |
|
|
29 |
|
|
30 |
+ |
import java.util.concurrent.*; |
31 |
|
import java.util.concurrent.atomic.AtomicInteger; |
31 |
– |
import java.util.concurrent.atomic.AtomicLong; |
32 |
|
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; |
33 |
< |
import java.util.concurrent.*; |
33 |
> |
import java.util.concurrent.atomic.AtomicLong; |
34 |
|
import java.util.concurrent.locks.*; |
35 |
|
|
36 |
|
public class CASLoops { |
46 |
|
if (args.length > 0) |
47 |
|
maxThreads = Integer.parseInt(args[0]); |
48 |
|
|
49 |
< |
loopIters = new long[maxThreads+1]; |
49 |
> |
loopIters = new long[maxThreads+1]; |
50 |
|
|
51 |
|
if (args.length > 1) |
52 |
|
includeLocks = true; |
569 |
|
if (nthreads > NCPUS) |
570 |
|
t = t * NCPUS / nthreads; |
571 |
|
System.out.print(LoopHelpers.rightJustify(t)); |
572 |
< |
double secs = (double)(runtime) / 1000000000.0; |
572 |
> |
double secs = (double) runtime / 1000000000.0; |
573 |
|
System.out.println("\t " + secs + "s run time"); |
574 |
|
} |
575 |
|
|
579 |
|
System.out.println("threads : " + i + |
580 |
|
" base iters per thread per run : " + |
581 |
|
LoopHelpers.rightJustify(loopIters[i])); |
582 |
< |
long ntime = runNonAtomic(i, iters); |
582 |
> |
long ntime = runNonAtomic(i, iters); |
583 |
|
if (print) |
584 |
|
report("Base : ", ntime, ntime, i, iters); |
585 |
|
Thread.sleep(100L); |