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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations