diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-12-16 10:45:53 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-12-16 10:45:53 +0100 |
commit | 89f78acf41592f4a16b390a13c3e763907012c4f (patch) | |
tree | 3c3125f6755d30d128698ffdc7c4823805ec9a1b /vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java | |
parent | b51e97ba22be851e7ad028edc0eaf62251988931 (diff) |
Cleanup
Diffstat (limited to 'vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java')
-rw-r--r-- | vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java b/vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java index 5ce53f2604b..dc0b3c47c62 100644 --- a/vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java +++ b/vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java @@ -19,7 +19,7 @@ public class TensorFunctionBenchmark { private final static Random random = new Random(); public double benchmark(int iterations, List<Tensor> modelVectors, TensorType.Dimension.Type dimensionType) { - Tensor queryVector = generateVectors(1, 300, dimensionType).get(0); + Tensor queryVector = vectors(1, 300, dimensionType).get(0); dotProduct(queryVector, modelVectors, Math.max(iterations/10, 10)); // warmup long startTime = System.currentTimeMillis(); dotProduct(queryVector, modelVectors, iterations); @@ -51,8 +51,7 @@ public class TensorFunctionBenchmark { return largest; } - private static List<Tensor> generateVectors(int vectorCount, int vectorSize, - TensorType.Dimension.Type dimensionType) { + private static List<Tensor> vectors(int vectorCount, int vectorSize, TensorType.Dimension.Type dimensionType) { List<Tensor> tensors = new ArrayList<>(); TensorType type = new TensorType.Builder().dimension("x", dimensionType).build(); for (int i = 0; i < vectorCount; i++) { @@ -65,8 +64,7 @@ public class TensorFunctionBenchmark { return tensors; } - private static List<Tensor> generateMatrix(int vectorCount, int vectorSize, - TensorType.Dimension.Type dimensionType) { + private static List<Tensor> matrix(int vectorCount, int vectorSize, TensorType.Dimension.Type dimensionType) { TensorType type = new TensorType.Builder().dimension("i", dimensionType).dimension("x", dimensionType).build(); Tensor.Builder builder = Tensor.Builder.of(type); for (int i = 0; i < vectorCount; i++) { @@ -88,11 +86,11 @@ public class TensorFunctionBenchmark { // - After adding type: 300 ms // - After sorting dimensions: 100 ms // - After special-casing single space: 2.4 ms - time = new TensorFunctionBenchmark().benchmark(5000, generateVectors(100, 300, TensorType.Dimension.Type.mapped), TensorType.Dimension.Type.mapped); + time = new TensorFunctionBenchmark().benchmark(5000, vectors(100, 300, TensorType.Dimension.Type.mapped), TensorType.Dimension.Type.mapped); System.out.printf("Mapped vectors, time per join: %1$8.3f ms\n", time); // Initial: 760 ms // - After special-casing subspace: 15 ms - time = new TensorFunctionBenchmark().benchmark(500, generateMatrix(100, 300, TensorType.Dimension.Type.mapped), TensorType.Dimension.Type.mapped); + time = new TensorFunctionBenchmark().benchmark(500, matrix(100, 300, TensorType.Dimension.Type.mapped), TensorType.Dimension.Type.mapped); System.out.printf("Mapped matrix, time per join: %1$8.3f ms\n", time); // ---------------- Indexed: @@ -100,11 +98,12 @@ public class TensorFunctionBenchmark { // - After special casing join: 3.6 ms // - After special-casing reduce: 0.80 ms // - After create IndexedTensor without builder: 0.41 ms - time = new TensorFunctionBenchmark().benchmark(5000, generateVectors(100, 300, TensorType.Dimension.Type.indexedUnbound),TensorType.Dimension.Type.indexedUnbound); + // - After double-array backing: 0.09 ms + time = new TensorFunctionBenchmark().benchmark(10000, vectors(100, 300, TensorType.Dimension.Type.indexedUnbound), TensorType.Dimension.Type.indexedUnbound); System.out.printf("Indexed vectors, time per join: %1$8.3f ms\n", time); // Initial: 3500 ms // - After special-casing subspace: 28 ms - time = new TensorFunctionBenchmark().benchmark(500, generateMatrix(100, 300, TensorType.Dimension.Type.indexedUnbound), TensorType.Dimension.Type.indexedUnbound); + time = new TensorFunctionBenchmark().benchmark(500, matrix(100, 300, TensorType.Dimension.Type.indexedUnbound), TensorType.Dimension.Type.indexedUnbound); System.out.printf("Indexed matrix, time per join: %1$8.3f ms\n", time); } |