Search in sources :

Example 6 with TimeTracker

use of com.yahoo.search.statistics.TimeTracker in project vespa by vespa-engine.

the class JsonRendererTestCase method testTimingRendering.

@Test
public final void testTimingRendering() throws InterruptedException, ExecutionException, JsonParseException, JsonMappingException, IOException {
    String expected = "{" + "    \"root\": {" + "        \"fields\": {" + "            \"totalCount\": 0" + "        }," + "        \"id\": \"toplevel\"," + "        \"relevance\": 1.0" + "    }," + "    \"timing\": {" + "        \"querytime\": 0.006," + "        \"searchtime\": 0.007," + "        \"summaryfetchtime\": 0.0" + "    }" + "}";
    Result r = new Result(new Query("/?renderer.json.debug=true&presentation.timing=true"));
    TimeTracker t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    ElapsedTimeTestCase.doInjectTimeSource(t, new CreativeTimeSource(new long[] { 1L, 2L, 3L, 4L, 5L, 6L, 7L }));
    t.sampleSearch(0, true);
    t.sampleSearch(1, true);
    t.sampleSearch(2, true);
    t.sampleSearch(3, true);
    t.sampleSearchReturn(2, true, null);
    t.sampleSearchReturn(1, true, null);
    t.sampleSearchReturn(0, true, null);
    r.getElapsedTime().add(t);
    renderer.setTimeSource(() -> 8L);
    String summary = render(r);
    System.out.println(summary);
    assertEqualJson(expected, summary);
}
Also used : UselessSearcher(com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher) Query(com.yahoo.search.Query) CreativeTimeSource(com.yahoo.search.statistics.ElapsedTimeTestCase.CreativeTimeSource) TimeTracker(com.yahoo.search.statistics.TimeTracker) Searcher(com.yahoo.search.Searcher) UselessSearcher(com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher) JSONString(com.yahoo.prelude.hitfield.JSONString) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 7 with TimeTracker

use of com.yahoo.search.statistics.TimeTracker in project vespa by vespa-engine.

the class ElapsedTimeTestCase method testMixedActivity.

public void testMixedActivity() {
    TimeTracker t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    runSomeTraffic(t);
    SearcherTimer[] searchers = t.searcherTracking();
    assertEquals(Long.valueOf(1L), searchers[0].getInvoking(Activity.SEARCH));
    assertNull(searchers[0].getInvoking(Activity.FILL));
    assertEquals(Long.valueOf(2L), searchers[0].getReturning(Activity.SEARCH));
    assertEquals(Long.valueOf(2L), searchers[0].getReturning(Activity.FILL));
    assertEquals(Long.valueOf(2L), searchers[1].getInvoking(Activity.SEARCH));
    assertEquals(Long.valueOf(2L), searchers[1].getInvoking(Activity.FILL));
    assertEquals(Long.valueOf(2L), searchers[1].getReturning(Activity.SEARCH));
    assertEquals(Long.valueOf(2L), searchers[1].getReturning(Activity.FILL));
    assertEquals(Long.valueOf(2L), searchers[2].getInvoking(Activity.SEARCH));
    assertEquals(Long.valueOf(2L), searchers[2].getInvoking(Activity.FILL));
    assertNull(searchers[2].getReturning(Activity.SEARCH));
    assertNull(searchers[2].getReturning(Activity.FILL));
}
Also used : TimeTracker(com.yahoo.search.statistics.TimeTracker) Searcher(com.yahoo.search.Searcher) SearcherTimer(com.yahoo.search.statistics.TimeTracker.SearcherTimer)

Example 8 with TimeTracker

use of com.yahoo.search.statistics.TimeTracker in project vespa by vespa-engine.

the class ElapsedTimeTestCase method testBasicBreakdownReturnInsideSearchChain.

public void testBasicBreakdownReturnInsideSearchChain() {
    TimeTracker t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    t.injectTimeSource(new CreativeTimeSource(new long[] { 1L, 2L, 3L, 4L, 5L, 6L }));
    t.sampleSearch(0, true);
    t.sampleSearch(1, true);
    t.sampleSearch(2, true);
    t.sampleSearchReturn(2, true, null);
    t.sampleSearchReturn(1, true, null);
    t.sampleSearchReturn(0, true, null);
    SearcherTimer[] searchers = t.searcherTracking();
    assertEquals(Long.valueOf(1L), searchers[0].getInvoking(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[1].getInvoking(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[2].getInvoking(Activity.SEARCH));
    assertNull(searchers[2].getReturning(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[1].getReturning(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[0].getReturning(Activity.SEARCH));
}
Also used : TimeTracker(com.yahoo.search.statistics.TimeTracker) Searcher(com.yahoo.search.Searcher) SearcherTimer(com.yahoo.search.statistics.TimeTracker.SearcherTimer)

Example 9 with TimeTracker

use of com.yahoo.search.statistics.TimeTracker in project vespa by vespa-engine.

the class ElapsedTimeTestCase method testBasicBreakdownWithFill.

public void testBasicBreakdownWithFill() {
    TimeTracker t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    t.injectTimeSource(new CreativeTimeSource(new long[] { 1L, 2L, 3L, 4L, 5L, 6L, 7L, 7L, 8L, 9L, 10L }));
    t.sampleSearch(0, true);
    t.sampleSearch(1, true);
    t.sampleSearch(2, true);
    t.sampleSearch(3, true);
    t.sampleSearchReturn(2, true, null);
    t.sampleSearchReturn(1, true, null);
    t.sampleSearchReturn(0, true, null);
    t.sampleFill(0, true);
    t.sampleFill(1, true);
    t.sampleFillReturn(1, true, null);
    t.sampleFillReturn(0, true, null);
    SearcherTimer[] searchers = t.searcherTracking();
    assertEquals(Long.valueOf(1L), searchers[0].getInvoking(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[1].getInvoking(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[2].getInvoking(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[2].getReturning(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[1].getReturning(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[0].getReturning(Activity.SEARCH));
    assertEquals(Long.valueOf(1L), searchers[0].getInvoking(Activity.FILL));
    assertEquals(Long.valueOf(1L), searchers[1].getInvoking(Activity.FILL));
    assertNull(searchers[1].getReturning(Activity.FILL));
    assertEquals(Long.valueOf(1L), searchers[0].getReturning(Activity.FILL));
}
Also used : TimeTracker(com.yahoo.search.statistics.TimeTracker) Searcher(com.yahoo.search.Searcher) SearcherTimer(com.yahoo.search.statistics.TimeTracker.SearcherTimer)

Example 10 with TimeTracker

use of com.yahoo.search.statistics.TimeTracker in project vespa by vespa-engine.

the class XMLRendererTestCase method testImplicitDefaultRender.

@Test
public final void testImplicitDefaultRender() throws Exception {
    Query q = new Query("/?query=a&tracelevel=5&reportCoverage=true");
    q.getPresentation().setTiming(true);
    Result r = new Result(q);
    r.setCoverage(new Coverage(500, 1, true));
    TimeTracker t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    ElapsedTimeTestCase.doInjectTimeSource(t, new CreativeTimeSource(new long[] { 1L, 2L, 3L, 4L, 5L, 6L, 7L }));
    t.sampleSearch(0, true);
    t.sampleSearch(1, true);
    t.sampleSearch(2, true);
    t.sampleSearch(3, true);
    t.sampleSearchReturn(2, true, null);
    t.sampleSearchReturn(1, true, null);
    t.sampleSearchReturn(0, true, null);
    r.getElapsedTime().add(t);
    r.getTemplating().setRenderer(d);
    FastHit h = new FastHit("http://localhost/", .95);
    h.setField("$a", "Hello, world.");
    h.setField("b", "foo");
    r.hits().add(h);
    HitGroup g = new HitGroup("usual");
    h = new FastHit("http://localhost/1", .90);
    h.setField("c", "d");
    g.add(h);
    r.hits().add(g);
    HitGroup gg = new HitGroup("type grouphit");
    gg.types().add("grouphit");
    gg.setField("e", "f");
    r.hits().add(gg);
    r.hits().addError(ErrorMessage.createInternalServerError("boom"));
    ByteArrayOutputStream bs = new ByteArrayOutputStream();
    ListenableFuture<Boolean> f = d.render(bs, r, null, null);
    assertTrue(f.get());
    String summary = Utf8.toString(bs.toByteArray());
    assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<result total-hit-count=\"0\"", summary.substring(0, 67));
    assertTrue(summary.contains("<meta type=\"context\">"));
    assertTrue(summary.contains("<error code=\"18\">Internal server error.</error>"));
    assertTrue(summary.contains("<hit type=\"grouphit\" relevancy=\"1.0\">"));
    assertTrue(summary.contains("<hit type=\"summary\" relevancy=\"0.95\">"));
    assertEquals(2, occurrences("<error ", summary));
    assertTrue(summary.length() > 1000);
}
Also used : Query(com.yahoo.search.Query) CreativeTimeSource(com.yahoo.search.statistics.ElapsedTimeTestCase.CreativeTimeSource) Searcher(com.yahoo.search.Searcher) UselessSearcher(com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher) Coverage(com.yahoo.search.result.Coverage) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Result(com.yahoo.search.Result) UselessSearcher(com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher) FastHit(com.yahoo.prelude.fastsearch.FastHit) TimeTracker(com.yahoo.search.statistics.TimeTracker) HitGroup(com.yahoo.search.result.HitGroup) Test(org.junit.Test)

Aggregations

TimeTracker (com.yahoo.search.statistics.TimeTracker)10 Searcher (com.yahoo.search.Searcher)8 Query (com.yahoo.search.Query)5 Result (com.yahoo.search.Result)5 SearcherTimer (com.yahoo.search.statistics.TimeTracker.SearcherTimer)4 CreativeTimeSource (com.yahoo.search.statistics.ElapsedTimeTestCase.CreativeTimeSource)3 UselessSearcher (com.yahoo.search.statistics.ElapsedTimeTestCase.UselessSearcher)3 Test (org.junit.Test)3 FastHit (com.yahoo.prelude.fastsearch.FastHit)2 Coverage (com.yahoo.search.result.Coverage)2 HitGroup (com.yahoo.search.result.HitGroup)2 ElapsedTime (com.yahoo.search.statistics.ElapsedTime)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Chain (com.yahoo.component.chain.Chain)1 JSONString (com.yahoo.prelude.hitfield.JSONString)1