}
static void runPerformanceTest(int numRows, int numCols, int numLookups, String mapType) {
SortedMap<Key,Value> tm = null;
NativeMap nm = null;
if (mapType.equals("SKIP_LIST"))
tm = new ConcurrentSkipListMap<Key,Value>();
else if (mapType.equals("TREE_MAP"))
tm = Collections.synchronizedSortedMap(new TreeMap<Key,Value>());
else if (mapType.equals("NATIVE_MAP"))
nm = new NativeMap();
else
throw new IllegalArgumentException(" map type must be SKIP_LIST, TREE_MAP, or NATIVE_MAP");
Random rand = new Random(19);
// puts
long tps = System.currentTimeMillis();
if (nm != null) {
for (int i = 0; i < numRows; i++) {
int row = rand.nextInt(1000000000);
Mutation m = nm(row);
for (int j = 0; j < numCols; j++) {
int col = rand.nextInt(1000000);
Value val = new Value("test".getBytes());
pc(m, col, val);
}
nm.mutate(m, i);
}
} else {
for (int i = 0; i < numRows; i++) {
int row = rand.nextInt(1000000000);
for (int j = 0; j < numCols; j++) {
int col = rand.nextInt(1000000);
Key key = nk(row, col);
Value val = new Value("test".getBytes());
tm.put(key, val);
}
}
}
long tpe = System.currentTimeMillis();
// Iteration
Iterator<Entry<Key,Value>> iter;
if (nm != null) {
iter = nm.iterator();
} else {
iter = tm.entrySet().iterator();
}
long tis = System.currentTimeMillis();
while (iter.hasNext()) {
iter.next();
}
long tie = System.currentTimeMillis();
rand = new Random(19);
int rowsToLookup[] = new int[numLookups];
int colsToLookup[] = new int[numLookups];
for (int i = 0; i < Math.min(numLookups, numRows); i++) {
int row = rand.nextInt(1000000000);
int col = -1;
for (int j = 0; j < numCols; j++) {
col = rand.nextInt(1000000);
}
rowsToLookup[i] = row;
colsToLookup[i] = col;
}
// get
long tgs = System.currentTimeMillis();
if (nm != null) {
for (int i = 0; i < numLookups; i++) {
Key key = nk(rowsToLookup[i], colsToLookup[i]);
if (nm.get(key) == null) {
throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i);
}
}
} else {
for (int i = 0; i < numLookups; i++) {
Key key = nk(rowsToLookup[i], colsToLookup[i]);
if (tm.get(key) == null) {
throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i);
}
}
}
long tge = System.currentTimeMillis();
long memUsed = 0;
if (nm != null) {
memUsed = nm.getMemoryUsed();
}
int size = (nm == null ? tm.size() : nm.size());
// delete
long tds = System.currentTimeMillis();
if (nm != null)
nm.delete();
long tde = System.currentTimeMillis();
if (tm != null)
tm.clear();