You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by jm...@apache.org on 2010/02/22 22:22:39 UTC
svn commit: r915074 -
/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java
Author: jmannix
Date: Mon Feb 22 21:22:39 2010
New Revision: 915074
URL: http://svn.apache.org/viewvc?rev=915074&view=rev
Log:
Add cross-implementation distance metric benchmarks.
Modified:
lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java
Modified: lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java?rev=915074&r1=915073&r2=915074&view=diff
==============================================================================
--- lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java (original)
+++ lucene/mahout/trunk/utils/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java Mon Feb 22 21:22:39 2010
@@ -298,7 +298,7 @@
}
}
// print result to prevent hotspot from eliminating deadcode
- printStats(stats, "DotProduct", "Dense.dot(Rand)", "sum = " + result + ' ');
+ printStats(stats, "DotProduct", "Dense.fn(Rand)", "sum = " + result + ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
@@ -309,7 +309,7 @@
}
}
// print result to prevent hotspot from eliminating deadcode
- printStats(stats, "DotProduct", "Dense.dot(Seq)", "sum = " + result + ' ');
+ printStats(stats, "DotProduct", "Dense.fn(Seq)", "sum = " + result + ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
@@ -320,7 +320,7 @@
}
}
// print result to prevent hotspot from eliminating deadcode
- printStats(stats, "DotProduct", "Rand.dot(Dense)", "sum = " + result + ' ');
+ printStats(stats, "DotProduct", "Rand.fn(Dense)", "sum = " + result + ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
@@ -331,7 +331,7 @@
}
}
// print result to prevent hotspot from eliminating deadcode
- printStats(stats, "DotProduct", "Rand.dot(Seq)", "sum = " + result + ' ');
+ printStats(stats, "DotProduct", "Rand.fn(Seq)", "sum = " + result + ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
@@ -342,7 +342,7 @@
}
}
// print result to prevent hotspot from eliminating deadcode
- printStats(stats, "DotProduct", "Seq.dot(Dense)", "sum = " + result + ' ');
+ printStats(stats, "DotProduct", "Seq.fn(Dense)", "sum = " + result + ' ');
result = 0;
stats = new TimingStatistics();
for (int l = 0; l < loop; l++) {
@@ -353,7 +353,7 @@
}
}
// print result to prevent hotspot from eliminating deadcode
- printStats(stats, "DotProduct", "Seq.dot(Rand)", "sum = " + result + ' ');
+ printStats(stats, "DotProduct", "Seq.fn(Rand)", "sum = " + result + ' ');
}
@@ -415,6 +415,117 @@
// 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;
+ }
+ }
+ result += minDistance;
+ call.end();
+ }
+ }
+ // print result to prevent hotspot from eliminating deadcode
+ printStats(stats, measure.getClass().getName(), "Seq.fn(Rand)", "minDistance = " + result
+ + ' ');
}
@@ -491,7 +602,7 @@
mark.distanceMeasureBenchmark(new CosineDistanceMeasure());
mark.distanceMeasureBenchmark(new SquaredEuclideanDistanceMeasure());
mark.distanceMeasureBenchmark(new EuclideanDistanceMeasure());
- mark.distanceMeasureBenchmark(new ManhattanDistanceMeasure());
+ //mark.distanceMeasureBenchmark(new ManhattanDistanceMeasure());
mark.distanceMeasureBenchmark(new TanimotoDistanceMeasure());
log.info("\n{}", mark.summarize());