21 |
|
static final long NPS = (1000L * 1000 * 1000); |
22 |
|
|
23 |
|
static int tasksPerPhaser = Math.max(NCPUS / 4, 4); |
24 |
< |
|
24 |
> |
|
25 |
|
static void build(Runnable[] actions, int sz, int lo, int hi, Phaser b) { |
26 |
|
int step = (hi - lo) / tasksPerPhaser; |
27 |
|
if (step > 1) { |
33 |
|
} |
34 |
|
} |
35 |
|
else { |
36 |
< |
for (int i = lo; i < hi; ++i) |
36 |
> |
for (int i = lo; i < hi; ++i) |
37 |
|
actions[i] = new PhaserAction(i, b, sz); |
38 |
|
} |
39 |
|
} |
69 |
|
nthreads = Integer.parseInt(args[0]); |
70 |
|
if (args.length > 1) |
71 |
|
tasksPerPhaser = Integer.parseInt(args[1]); |
72 |
< |
|
72 |
> |
|
73 |
|
System.out.printf("Max %d Threads, %d tasks per phaser\n", nthreads, tasksPerPhaser); |
74 |
|
|
75 |
|
for (int k = 2; k <= nthreads; k *= 2) { |
76 |
|
for (int size = FIRST_SIZE; size <= LAST_SIZE; size *= 10) { |
77 |
|
long startTime = System.nanoTime(); |
78 |
< |
|
78 |
> |
|
79 |
|
Runnable[] actions = new Runnable [k]; |
80 |
|
build(actions, size, 0, k, new Phaser()); |
81 |
|
Future[] futures = new Future[k]; |
93 |
|
} |
94 |
|
pool.shutdown(); |
95 |
|
} |
96 |
– |
|
97 |
– |
} |
98 |
– |
|
96 |
|
|
97 |
+ |
} |