aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test/java/com/yahoo/tensor/functions
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-12-16 10:07:30 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2019-12-16 10:07:30 +0100
commitbaa6a81aa07f37a543c836710b4c65b7831fd9db (patch)
tree7e0724c298a1b45f356956b897133c07b618dff5 /vespajlib/src/test/java/com/yahoo/tensor/functions
parent45992cec4b915513372b1d8e777e505aaee3f4a1 (diff)
parent65dd6eb4932a7c29cbad7d717bc34da73d0bb723 (diff)
Merge with master
Diffstat (limited to 'vespajlib/src/test/java/com/yahoo/tensor/functions')
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/functions/DynamicTensorTestCase.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/functions/DynamicTensorTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/functions/DynamicTensorTestCase.java
index 7cddeab1641..2231d32281a 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/functions/DynamicTensorTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/functions/DynamicTensorTestCase.java
@@ -6,6 +6,7 @@ import com.yahoo.tensor.TensorAddress;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.evaluation.EvaluationContext;
import com.yahoo.tensor.evaluation.Name;
+import org.junit.Ignore;
import org.junit.Test;
import java.util.Collections;
@@ -46,10 +47,23 @@ public class DynamicTensorTestCase {
new Constant(5));
values.put(new TensorAddress.Builder(sparse).add("x", "a").add("y", "c").build(),
new Constant(7));
- DynamicTensor<Name> t2 = DynamicTensor.from(sparse, values);
+ DynamicTensor<Name> t2 = DynamicTensor.from(sparse, values);
assertEquals(Tensor.from(sparse, "{{x:a,y:b}:5, {x:a,y:c}:7}"), t2.evaluate());
}
+ @Ignore // Enable for benchmarking
+ public void benchMarkTensorAddressBuilder() {
+ long start = System.nanoTime();
+ TensorType sparse = TensorType.fromSpec("tensor(x{})");
+ for (int i=0; i < 10000; i++) {
+ TensorAddress.Builder builder = new TensorAddress.Builder(sparse);
+ for (int j=0; j < 1000; j++) {
+ builder.add("x", String.valueOf(j));
+ }
+ }
+ System.out.println("Took " + (System.nanoTime() - start) + " ns");
+ }
+
private static class Constant implements ScalarFunction<Name> {
private final double value;