}
public void distanceMeasureBenchmark(DistanceMeasure measure) {
double result = 0;
TimingStatistics stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
for (int i = 0; i < numVectors; i++) {
TimingStatistics.Call call = stats.newCall();
double minDistance = Double.MAX_VALUE;
for (int u = 0; u < opsPerUnit; u++) {
double distance = measure.distance(vectors[0][i], vectors[0][u]);
if (distance < minDistance) {
minDistance = distance;
}
}
result += minDistance;
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, measure.getClass().getName(), "DenseVector", "minDistance = " + result + ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
for (int i = 0; i < numVectors; i++) {
TimingStatistics.Call call = stats.newCall();
double minDistance = Double.MAX_VALUE;
for (int u = 0; u < opsPerUnit; u++) {
double distance = measure.distance(vectors[1][i], vectors[1][u]);
if (distance < minDistance) {
minDistance = distance;
}
}
result += minDistance;
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, measure.getClass().getName(), "RandSparseVector", "minDistance = " + result
+ ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
for (int i = 0; i < numVectors; i++) {
TimingStatistics.Call call = stats.newCall();
double minDistance = Double.MAX_VALUE;
for (int u = 0; u < opsPerUnit; u++) {
double distance = measure.distance(vectors[2][i], vectors[2][u]);
if (distance < minDistance) {
minDistance = distance;
}
}
result += minDistance;
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, measure.getClass().getName(), "SeqSparseVector", "minDistance = " + result
+ ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
for (int i = 0; i < numVectors; i++) {
TimingStatistics.Call call = stats.newCall();
double minDistance = Double.MAX_VALUE;
for (int u = 0; u < opsPerUnit; u++) {
double distance = measure.distance(vectors[0][i], vectors[1][u]);
if (distance < minDistance) {
minDistance = distance;
}
}
result += minDistance;
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, measure.getClass().getName(), "Dense.fn(Rand)", "minDistance = " + result + ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
for (int i = 0; i < numVectors; i++) {
TimingStatistics.Call call = stats.newCall();
double minDistance = Double.MAX_VALUE;
for (int u = 0; u < opsPerUnit; u++) {
double distance = measure.distance(vectors[0][i], vectors[2][u]);
if (distance < minDistance) {
minDistance = distance;
}
}
result += minDistance;
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, measure.getClass().getName(), "Dense.fn(Seq)", "minDistance = " + result
+ ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
for (int i = 0; i < numVectors; i++) {
TimingStatistics.Call call = stats.newCall();
double minDistance = Double.MAX_VALUE;
for (int u = 0; u < opsPerUnit; u++) {
double distance = measure.distance(vectors[1][i], vectors[0][u]);
if (distance < minDistance) {
minDistance = distance;
}
}
result += minDistance;
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, measure.getClass().getName(), "Rand.fn(Dense)", "minDistance = " + result
+ ' ');
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
for (int i = 0; i < numVectors; i++) {
TimingStatistics.Call call = stats.newCall();
double minDistance = Double.MAX_VALUE;
for (int u = 0; u < opsPerUnit; u++) {
double distance = measure.distance(vectors[1][i], vectors[2][u]);
if (distance < minDistance) {
minDistance = distance;
}
}
result += minDistance;
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, measure.getClass().getName(), "Rand.fn(Seq)", "minDistance = " + result + ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
for (int i = 0; i < numVectors; i++) {
TimingStatistics.Call call = stats.newCall();
double minDistance = Double.MAX_VALUE;
for (int u = 0; u < opsPerUnit; u++) {
double distance = measure.distance(vectors[2][i], vectors[0][u]);
if (distance < minDistance) {
minDistance = distance;
}
}
result += minDistance;
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, measure.getClass().getName(), "Seq.fn(Dense)", "minDistance = " + result
+ ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
for (int i = 0; i < numVectors; i++) {
TimingStatistics.Call call = stats.newCall();
double minDistance = Double.MAX_VALUE;
for (int u = 0; u < opsPerUnit; u++) {
double distance = measure.distance(vectors[2][i], vectors[1][u]);
if (distance < minDistance) {
minDistance = distance;