Search in sources :

Example 1 with TimeTracker

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

the class SyncDefaultRendererTestCase method testRenderWriterResult.

@SuppressWarnings("deprecation")
@Test
public final void testRenderWriterResult() throws IOException, InterruptedException, ExecutionException {
    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());
    // TODO figure out a reasonably strict and reasonably flexible way to test
    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)

Example 2 with TimeTracker

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

the class ElapsedTimeTestCase method testBasicBreakdown.

public void testBasicBreakdown() {
    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 }));
    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);
    SearcherTimer[] searchers = t.searcherTracking();
    checkTiming(searchers);
}
Also used : TimeTracker(com.yahoo.search.statistics.TimeTracker) Searcher(com.yahoo.search.Searcher) SearcherTimer(com.yahoo.search.statistics.TimeTracker.SearcherTimer)

Example 3 with TimeTracker

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

the class ElapsedTimeTestCase method testMultiSearchAndPing.

public void testMultiSearchAndPing() {
    TimeTracker t = new TimeTracker(null);
    t.injectTimeSource(new CreativeTimeSource(new long[] { 1L, 4L, 16L, 32L, 64L, 128L, 256L }));
    Query q = new Query();
    Result r = new Result(q);
    t.sampleSearch(0, false);
    t.samplePing(0, false);
    t.sampleSearch(0, false);
    t.samplePing(0, false);
    t.sampleSearch(0, false);
    t.sampleFill(0, false);
    t.sampleSearchReturn(0, false, r);
    assertEquals(1L, t.first());
    assertEquals(256L, t.last());
    assertEquals(128L, t.firstFill());
    assertEquals(83L, t.searchTime());
    assertEquals(128L, t.fillTime());
    assertEquals(44L, t.pingTime());
    assertEquals(255L, t.totalTime());
    ElapsedTime e = new ElapsedTime();
    e.add(t);
    e.add(t);
    // multiple adds is supposed to be safe
    assertEquals(255L, t.totalTime());
    TimeTracker tx = new TimeTracker(null);
    tx.injectTimeSource(new CreativeTimeSource(new long[] { 1L, 2L, 3L, 4L }));
    Query qx = new Query();
    Result rx = new Result(qx);
    tx.sampleSearch(0, false);
    tx.sampleFill(0, false);
    tx.samplePing(0, false);
    tx.sampleSearchReturn(0, false, rx);
    e.add(tx);
    assertEquals(258L, e.totalTime());
    assertEquals(129L, e.fillTime());
    assertEquals(2L, e.firstFill());
}
Also used : Query(com.yahoo.search.Query) TimeTracker(com.yahoo.search.statistics.TimeTracker) ElapsedTime(com.yahoo.search.statistics.ElapsedTime) Result(com.yahoo.search.Result)

Example 4 with TimeTracker

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

the class ElapsedTimeTestCase method testReportGeneration.

public void testReportGeneration() {
    TimeTracker t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    runSomeTraffic(t);
    ElapsedTime elapsed = new ElapsedTime();
    elapsed.add(t);
    t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
    runSomeTraffic(t);
    elapsed.add(t);
    assertEquals(true, elapsed.hasDetailedData());
    assertEquals("Time use per searcher:" + " first(QueryProcessing(SEARCH: 2 ms), ResultProcessing(SEARCH: 4 ms, FILL: 4 ms)),\n" + "    second(QueryProcessing(SEARCH: 4 ms, FILL: 4 ms), ResultProcessing(SEARCH: 4 ms, FILL: 4 ms)),\n" + "    third(QueryProcessing(SEARCH: 4 ms, FILL: 4 ms), ResultProcessing()).", elapsed.detailedReport());
}
Also used : Chain(com.yahoo.component.chain.Chain) TimeTracker(com.yahoo.search.statistics.TimeTracker) Searcher(com.yahoo.search.Searcher) ElapsedTime(com.yahoo.search.statistics.ElapsedTime)

Example 5 with TimeTracker

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

the class ElapsedTimeTestCase method testBasic.

public void testBasic() {
    TimeTracker t = new TimeTracker(null);
    t.injectTimeSource(new CreativeTimeSource(new long[] { 1L, 2L, 3L, 4L }));
    Query q = new Query();
    Result r = new Result(q);
    t.sampleSearch(0, false);
    t.sampleFill(0, false);
    t.samplePing(0, false);
    t.sampleSearchReturn(0, false, r);
    assertEquals(1L, t.first());
    assertEquals(4L, t.last());
    assertEquals(2L, t.firstFill());
    assertEquals(1L, t.searchTime());
    assertEquals(1L, t.fillTime());
    assertEquals(1L, t.pingTime());
    assertEquals(3L, t.totalTime());
}
Also used : Query(com.yahoo.search.Query) TimeTracker(com.yahoo.search.statistics.TimeTracker) Result(com.yahoo.search.Result)

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