4 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
– |
import java.util.*; |
7 |
|
import java.io.*; |
8 |
|
import java.math.*; |
9 |
+ |
import java.util.*; |
10 |
|
|
11 |
|
/** |
12 |
|
* A micro-benchmark with key types and operation mixes roughly |
38 |
|
public class MapMicroBenchmark { |
39 |
|
static final String wordFile = "testwords.txt"; |
40 |
|
|
41 |
< |
static Class mapClass; |
41 |
> |
static Class<?> mapClass; |
42 |
|
static boolean randomSearches = true; |
43 |
|
|
44 |
|
// Nanoseconds per run |
210 |
|
System.out.println("\n"); |
211 |
|
} |
212 |
|
|
213 |
– |
|
213 |
|
static final class Job { |
214 |
|
final String name; |
215 |
< |
final Class elementClass; |
215 |
> |
final Class<?> elementClass; |
216 |
|
long[] nanos = new long[nsizes]; |
217 |
|
final Object[] items; |
218 |
|
Object[] searches; |
219 |
|
volatile long checkSum; |
220 |
|
volatile int lastSum; |
221 |
< |
Job(String name, Object[] items, Class elementClass) { |
221 |
> |
Job(String name, Object[] items, Class<?> elementClass) { |
222 |
|
this.name = name; |
223 |
|
this.items = items; |
224 |
|
this.elementClass = elementClass; |
362 |
|
|
363 |
|
} |
364 |
|
|
366 |
– |
|
365 |
|
static final Random rng = new Random(3122688); |
366 |
|
|
367 |
|
// Shuffle the subarrays for each size. This doesn't fully |
381 |
|
|
382 |
|
// plain array shuffle |
383 |
|
static void shuffle(Object[] a, int size) { |
384 |
< |
for (int i= size; i>1; i--) { |
384 |
> |
for (int i = size; i > 1; i--) { |
385 |
|
Object t = a[i-1]; |
386 |
|
int r = rng.nextInt(i); |
387 |
|
a[i-1] = a[r]; |
442 |
|
|
443 |
|
BufferedInputStream in = new BufferedInputStream(fr); |
444 |
|
int k = 0; |
445 |
< |
outer:while (k < n) { |
445 |
> |
outer: while (k < n) { |
446 |
|
StringBuffer sb = new StringBuffer(); |
447 |
|
for (;;) { |
448 |
|
int c = in.read(); |