}
}
- public void expectLessThanOrEqualTo(String label, long val, long max) {
+ public void expectAround(String label, long val, long expect, double marginPercents) {
if (ENABLED) {
- checkThat(label, val, Matchers.lessThan(max));
+ if (marginPercents > 0.2) {
+ throw new IllegalArgumentException("Error margin must be less than 0.2 (20%). Has: " + marginPercents);
+ }
+ long min = (long) (expect * (1.0 - marginPercents));
+ long max = (long) (expect * (1.0 + marginPercents));
+ checkThat(label, val, Matchers.allOf(Matchers.greaterThan(min), Matchers.lessThan(max)));
}
}
long period = System.currentTimeMillis() - start;
long throughputPerSecond = 1000 * issues.count.get() / period;
LOGGER.info(String.format("%d issues indexed in %d ms (%d docs/second)", issues.count.get(), period, throughputPerSecond));
- benchmark.expectBetween("Throughput to index issues", throughputPerSecond, 3000, 3400);
+ benchmark.expectAround("Throughput to index issues", throughputPerSecond, 3000, 0.04);
// be sure that physical files do not evolve during estimation of size
tester.get(EsClient.class).prepareOptimize("issues").get();
@Rule
public DbTester dbTester = new DbTester();
+ @Rule
+ public Benchmark benchmark = new Benchmark();
+
@Test
public void benchmark() throws Exception {
prepareTable();
long period = end - start;
long throughputPerSecond = 1000L * counter.get() / period;
LOGGER.info(String.format("%d FILE_SOURCES rows scrolled in %d ms (%d rows/second)", counter.get(), period, throughputPerSecond));
+ benchmark.expectAround("Throughput to scroll FILE_SOURCES", throughputPerSecond, 120, 0.04);
} finally {
DbUtils.closeQuietly(connection);
long nbLines = files.count.get() * LINES_PER_FILE;
long throughputPerSecond = 1000L * nbLines / period;
LOGGER.info(String.format("%d lines indexed in %d ms (%d docs/second)", nbLines, period, throughputPerSecond));
- benchmark.expectBetween("Throughput to index source lines", throughputPerSecond, 7500, 8000);
+ benchmark.expectAround("Throughput to index source lines", throughputPerSecond, 7800, 0.04);
// be sure that physical files do not evolve during estimation of size
tester.get(EsClient.class).prepareOptimize(SourceLineIndexDefinition.INDEX).get();