}
public void dotBenchmark() {
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();
result += vectors[0][i].dot(vectors[0][(i + 1) % numVectors]);
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, "DotProduct", "DenseVector", "sum = " + 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();
result += vectors[1][i].dot(vectors[1][(i + 1) % numVectors]);
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, "DotProduct", "RandSparseVector", "sum = " + 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();
result += vectors[2][i].dot(vectors[2][(i + 1) % numVectors]);
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, "DotProduct", "SeqSparseVector", "sum = " + 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();
result += vectors[0][i].dot(vectors[1][(i + 1) % numVectors]);
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, "DotProduct", "Dense.fn(Rand)", "sum = " + 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();
result += vectors[0][i].dot(vectors[2][(i + 1) % numVectors]);
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, "DotProduct", "Dense.fn(Seq)", "sum = " + 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();
result += vectors[1][i].dot(vectors[0][(i + 1) % numVectors]);
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, "DotProduct", "Rand.fn(Dense)", "sum = " + 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();
result += vectors[1][i].dot(vectors[2][(i + 1) % numVectors]);
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, "DotProduct", "Rand.fn(Seq)", "sum = " + 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();
result += vectors[2][i].dot(vectors[0][(i + 1) % numVectors]);
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode
printStats(stats, "DotProduct", "Seq.fn(Dense)", "sum = " + 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();
result += vectors[2][i].dot(vectors[1][(i + 1) % numVectors]);
call.end();
}
}
// print result to prevent hotspot from eliminating deadcode