diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-28 15:32:49 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-28 17:41:46 +0200 |
commit | 5c885b760902a55bca26b4b6cd29ad8cca597233 (patch) | |
tree | 1669dabf1fc2f0878ee2545d7518bcfdc8ea6593 /container-search/src | |
parent | c15bbf195c4ece8a2f08c8ffc68b3b80fa9f28b2 (diff) |
Add benchmark for construction of Query object
Diffstat (limited to 'container-search/src')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java index c4541fe9f58..1a4ef7b7d62 100644 --- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java @@ -486,7 +486,8 @@ public class QueryProfileTestCase { assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"}))); } - public void testSettingNonLeaf4b() { + @Test + void testSettingNonLeaf4b() { QueryProfile p = new QueryProfile("test"); p.setDimensions(new String[] {"x"}); p.set("a","a-value", (QueryProfileRegistry)null); @@ -648,6 +649,32 @@ public class QueryProfileTestCase { assertTrue(traceContains("foo: value", query)); } + @Test + void benchQueryCreation() throws InterruptedException { + QueryProfile p = new QueryProfile("test"); + p.setDimensions(new String[]{"x", "y"}); + p.set("clustering.something", "bar", null); + p.set("clustering.something", "bar", new String[]{"x1", "y1"}, null); + p.freeze(); + CompiledQueryProfile cqp = p.compile(null); + var httpRequest = HttpRequest.createTestRequest("?x=x1&y=y1&query=bar&clustering.timeline.kano=tur&" + + "clustering.enable=true&clustering.timeline.bucketspec=-" + + "7d/3h&clustering.timeline.tophit=false&clustering.timeli" + + "ne=true", Method.GET); + for (int i = 0; i < 30000; i++) { + Query q = new Query(httpRequest, cqp); + assertTrue(q.properties().getBoolean("clustering.timeline", false)); + } + Thread.sleep(2000); + long start = System.nanoTime(); + for (int i = 0; i < 100000; i++) { + Query q = new Query(httpRequest, cqp); + assertTrue(q.properties().getBoolean("clustering.timeline", false)); + } + long now = System.nanoTime(); + System.out.println("Duration = " + (now - start)/1_000_000 + " ms"); + } + // NB: NOT RECURSIVE private boolean traceContains(String string, Query query) { for (TraceNode node : query.getContext(true).getTrace().traceNode().children()) |