Java Code Examples for org.elasticsearch.common.StopWatch#start()

The following examples show how to use org.elasticsearch.common.StopWatch#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenNlpService.java    From elasticsearch-ingest-opennlp with Apache License 2.0 6 votes vote down vote up
protected OpenNlpService start() {
    StopWatch sw = new StopWatch("models-loading");
    Map<String, String> settingsMap = IngestOpenNlpPlugin.MODEL_FILE_SETTINGS.getAsMap(settings);
    for (Map.Entry<String, String> entry : settingsMap.entrySet()) {
        String name = entry.getKey();
        sw.start(name);
        Path path = configDirectory.resolve(entry.getValue());
        try (InputStream is = Files.newInputStream(path)) {
            nameFinderModels.put(name, new TokenNameFinderModel(is));
        } catch (IOException e) {
            logger.error((Supplier<?>) () -> new ParameterizedMessage("Could not load model [{}] with path [{}]", name, path), e);
        }
        sw.stop();
    }

    if (settingsMap.keySet().size() == 0) {
        logger.error("Did not load any models for ingest-opennlp plugin, none configured");
    } else {
        logger.info("Read models in [{}] for {}", sw.totalTime(), settingsMap.keySet());
    }

    return this;
}
 
Example 2
Source File: JobCollectContext.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private void measureCollectTime() {
    final StopWatch stopWatch = new StopWatch(collectPhase.executionPhaseId() + ": " + collectPhase.name());
    stopWatch.start("starting collectors");
    listenableRowReceiver.finishFuture().addListener(new Runnable() {
        @Override
        public void run() {
            stopWatch.stop();
            logger.trace("Collectors finished: {}", stopWatch.shortSummary());
        }
    }, MoreExecutors.directExecutor());
}
 
Example 3
Source File: FlsPerfTest.java    From deprecated-security-advanced-modules with Apache License 2.0 4 votes vote down vote up
@Test
public void testFlsPerfNamed() throws Exception {

    setup();

    HttpResponse res;

    StopWatch sw = new StopWatch("testFlsPerfNamed");
    sw.start("non fls");
    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
    sw.stop();
    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    sw.start("with fls");
    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_named_only", "password"))).getStatusCode());
    sw.stop();
    Assert.assertFalse(res.getBody().contains("field1\""));
    Assert.assertFalse(res.getBody().contains("field2\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    sw.start("with fls 2 after warmup");

    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_named_only", "password"))).getStatusCode());
    sw.stop();

    Assert.assertFalse(res.getBody().contains("field1\""));
    Assert.assertFalse(res.getBody().contains("field2\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    sw.start("with fls 3 after warmup");

    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_named_only", "password"))).getStatusCode());
    sw.stop();

    Assert.assertFalse(res.getBody().contains("field1\""));
    Assert.assertFalse(res.getBody().contains("field2\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    System.out.println(sw.prettyPrint());
}
 
Example 4
Source File: FlsPerfTest.java    From deprecated-security-advanced-modules with Apache License 2.0 4 votes vote down vote up
@Test
public void testFlsPerfWcEx() throws Exception {

    setup();

    HttpResponse res;

    StopWatch sw = new StopWatch("testFlsPerfWcEx");
    sw.start("non fls");
    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
    sw.stop();
    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    sw.start("with fls");
    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_wc_ex", "password"))).getStatusCode());
    sw.stop();
    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertFalse(res.getBody().contains("field50\""));
    Assert.assertFalse(res.getBody().contains("field997\""));

    sw.start("with fls 2 after warmup");

    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_wc_ex", "password"))).getStatusCode());
    sw.stop();

    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertFalse(res.getBody().contains("field50\""));
    Assert.assertFalse(res.getBody().contains("field997\""));

    sw.start("with fls 3 after warmup");

    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_wc_ex", "password"))).getStatusCode());
    sw.stop();

    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertFalse(res.getBody().contains("field50\""));
    Assert.assertFalse(res.getBody().contains("field997\""));

    System.out.println(sw.prettyPrint());
}
 
Example 5
Source File: FlsPerfTest.java    From deprecated-security-advanced-modules with Apache License 2.0 4 votes vote down vote up
@Test
public void testFlsPerfNamedEx() throws Exception {

    setup();

    HttpResponse res;

    StopWatch sw = new StopWatch("testFlsPerfNamedEx");
    sw.start("non fls");
    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
    sw.stop();
    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    sw.start("with fls");
    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_named_ex", "password"))).getStatusCode());
    sw.stop();
    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertFalse(res.getBody().contains("field50\""));
    Assert.assertFalse(res.getBody().contains("field997\""));

    sw.start("with fls 2 after warmup");

    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_named_ex", "password"))).getStatusCode());
    sw.stop();

    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertFalse(res.getBody().contains("field50\""));
    Assert.assertFalse(res.getBody().contains("field997\""));

    sw.start("with fls 3 after warmup");

    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_named_ex", "password"))).getStatusCode());
    sw.stop();

    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertFalse(res.getBody().contains("field50\""));
    Assert.assertFalse(res.getBody().contains("field997\""));

    System.out.println(sw.prettyPrint());
}
 
Example 6
Source File: FlsPerfTest.java    From deprecated-security-advanced-modules with Apache License 2.0 4 votes vote down vote up
@Test
public void testFlsWcIn() throws Exception {

    setup();

    HttpResponse res;

    StopWatch sw = new StopWatch("testFlsWcIn");
    sw.start("non fls");
    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty", encodeBasicHeader("admin", "admin"))).getStatusCode());
    sw.stop();
    Assert.assertTrue(res.getBody().contains("field1\""));
    Assert.assertTrue(res.getBody().contains("field2\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    sw.start("with fls");
    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_wc_in", "password"))).getStatusCode());
    sw.stop();
    Assert.assertFalse(res.getBody().contains("field0\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    sw.start("with fls 2 after warmup");

    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_wc_in", "password"))).getStatusCode());
    sw.stop();

    Assert.assertFalse(res.getBody().contains("field0\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    sw.start("with fls 3 after warmup");

    Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/deals/_search?pretty&size=1000", encodeBasicHeader("perf_wc_in", "password"))).getStatusCode());
    sw.stop();

    Assert.assertFalse(res.getBody().contains("field0\""));
    Assert.assertTrue(res.getBody().contains("field50\""));
    Assert.assertTrue(res.getBody().contains("field997\""));

    System.out.println(sw.prettyPrint());
}
 
Example 7
Source File: FilterJoinBenchmark.java    From siren-join with GNU Affero General Public License v3.0 4 votes vote down vote up
public void setupIndex() {
    log("==== INDEX SETUP ====");
    try {
      client.admin().indices().create(createIndexRequest(PARENT_INDEX).mapping(PARENT_TYPE,
              "id", "type=string,index=not_analyzed,doc_values=true",
              "num", "type=integer,doc_values=true")).actionGet();
      client.admin().indices().create(createIndexRequest(CHILD_INDEX).mapping(CHILD_TYPE,
              "id", "type=string,index=not_analyzed,doc_values=true",
              "pid", "type=string,index=not_analyzed,doc_values=true",
              "num", "type=integer,doc_values=true")).actionGet();
        Thread.sleep(5000);

        StopWatch stopWatch = new StopWatch().start();

        log("Indexing [" + NUM_PARENTS + "] parent documents into [" + PARENT_INDEX + "]");
        log("Indexing [" + (NUM_PARENTS * NUM_CHILDREN_PER_PARENT) + "] child documents into [" + CHILD_INDEX + "]");
        int ITERS = NUM_PARENTS / BATCH_SIZE;
        int i = 1;
        int counter = 0;
        for (; i <= ITERS; i++) {
            BulkRequestBuilder request = client.prepareBulk();
            for (int j = 0; j < BATCH_SIZE; j++) {
                String parentId = Integer.toString(counter);
                counter++;
                request.add(Requests.indexRequest(PARENT_INDEX)
                        .type(PARENT_TYPE)
                        .id(parentId)
                        .source(parentSource(counter, "test" + counter)));

                for (int k = 0; k < NUM_CHILDREN_PER_PARENT; k++) {
                    String childId = parentId + "_" + k;
                    request.add(Requests.indexRequest(CHILD_INDEX)
                            .type(CHILD_TYPE)
                            .id(childId)
                            .source(childSource(childId, counter, "tag" + k)));
                }
            }

            BulkResponse response = request.execute().actionGet();
            if (response.hasFailures()) {
                log("Index Failures...");
            }

            if (((i * BATCH_SIZE) % 10000) == 0) {
                log("Indexed [" + (i * BATCH_SIZE) * (1 + NUM_CHILDREN_PER_PARENT) + "] took [" + stopWatch.stop().lastTaskTime() + "]");
                stopWatch.start();
            }
        }

        log("Indexing took [" + stopWatch.totalTime() + "]");
        log("TPS [" + (((double) (NUM_PARENTS * (1 + NUM_CHILDREN_PER_PARENT))) / stopWatch.totalTime().secondsFrac()) + "]");
    } catch (Exception e) {
        log("Indices exist, wait for green");
        waitForGreen();
    }

    client.admin().indices().prepareRefresh().execute().actionGet();
    log("Number of docs in index: " + client.prepareCount(PARENT_INDEX, CHILD_INDEX).setQuery(matchAllQuery()).execute().actionGet().getCount());
    log("");
}
 
Example 8
Source File: TermsByQueryBenchmark.java    From siren-join with GNU Affero General Public License v3.0 4 votes vote down vote up
public void setupIndex() {
    log("==== INDEX SETUP ====");
    try {
        client.admin().indices().create(createIndexRequest(PARENT_INDEX)).actionGet();
        client.admin().indices().create(createIndexRequest(CHILD_INDEX)).actionGet();
        Thread.sleep(5000);

        StopWatch stopWatch = new StopWatch().start();

        log("Indexing [" + NUM_PARENTS + "] parent documents into [" + PARENT_INDEX + "]");
        log("Indexing [" + (NUM_PARENTS * NUM_CHILDREN_PER_PARENT) + "] child documents into [" + CHILD_INDEX + "]");
        int ITERS = NUM_PARENTS / BATCH_SIZE;
        int i = 1;
        int counter = 0;
        for (; i <= ITERS; i++) {
            BulkRequestBuilder request = client.prepareBulk();
            for (int j = 0; j < BATCH_SIZE; j++) {
                String parentId = Integer.toString(counter);
                counter++;
                request.add(Requests.indexRequest(PARENT_INDEX)
                        .type(PARENT_TYPE)
                        .id(parentId)
                        .source(parentSource(counter, "test" + counter)));

                for (int k = 0; k < NUM_CHILDREN_PER_PARENT; k++) {
                    String childId = parentId + "_" + k;
                    request.add(Requests.indexRequest(CHILD_INDEX)
                            .type(CHILD_TYPE)
                            .id(childId)
                            .source(childSource(childId, counter, "tag" + k)));
                }
            }

            BulkResponse response = request.execute().actionGet();
            if (response.hasFailures()) {
                log("Index Failures...");
            }

            if (((i * BATCH_SIZE) % 10000) == 0) {
                log("Indexed [" + (i * BATCH_SIZE) * (1 + NUM_CHILDREN_PER_PARENT) + "] took [" + stopWatch.stop().lastTaskTime() + "]");
                stopWatch.start();
            }
        }

        log("Indexing took [" + stopWatch.totalTime() + "]");
        log("TPS [" + (((double) (NUM_PARENTS * (1 + NUM_CHILDREN_PER_PARENT))) / stopWatch.totalTime().secondsFrac()) + "]");
    } catch (Exception e) {
        log("Indices exist, wait for green");
        waitForGreen();
    }

    client.admin().indices().prepareRefresh().execute().actionGet();
    log("Number of docs in index: " + client.prepareCount(PARENT_INDEX, CHILD_INDEX).setQuery(matchAllQuery()).execute().actionGet().getCount());
    log("");
}