Search in sources :

Example 96 with Setup

use of org.openjdk.jmh.annotations.Setup in project crate by crate.

the class LuceneBatchIteratorBenchmark method createLuceneBatchIterator.

@Setup
public void createLuceneBatchIterator() throws Exception {
    IndexWriter iw = new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
    String columnName = "x";
    for (int i = 0; i < 10_000_000; i++) {
        Document doc = new Document();
        doc.add(new NumericDocValuesField(columnName, i));
        iw.addDocument(doc);
    }
    iw.commit();
    iw.forceMerge(1, true);
    indexSearcher = new IndexSearcher(DirectoryReader.open(iw));
    IntegerColumnReference columnReference = new IntegerColumnReference(columnName);
    columnRefs = Collections.singletonList(columnReference);
    collectorContext = new CollectorContext();
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) NumericDocValuesField(org.apache.lucene.document.NumericDocValuesField) IndexWriter(org.apache.lucene.index.IndexWriter) ByteBuffersDirectory(org.apache.lucene.store.ByteBuffersDirectory) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) IntegerColumnReference(io.crate.expression.reference.doc.lucene.IntegerColumnReference) CollectorContext(io.crate.expression.reference.doc.lucene.CollectorContext) Document(org.apache.lucene.document.Document) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Setup(org.openjdk.jmh.annotations.Setup)

Example 97 with Setup

use of org.openjdk.jmh.annotations.Setup in project crate by crate.

the class JsonReaderBenchmark method create_temp_file_and_uri.

@Setup
public void create_temp_file_and_uri() throws IOException {
    NodeContext nodeCtx = new NodeContext(new Functions(Map.of()));
    inputFactory = new InputFactory(nodeCtx);
    tempFile = File.createTempFile("temp", null);
    fileUri = tempFile.toURI().getPath();
    try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tempFile), StandardCharsets.UTF_8)) {
        writer.write("{\"name\": \"Arthur\", \"id\": 4\\n");
        writer.write("{\"id\": 5, \"name\": \"Trillian\"\n");
        writer.write("{\"id\": 5, \"name\": \"Emma\"\n");
        writer.write("{\"id\": 9, \"name\": \"Emily\"\n");
        writer.write("{\"id\": 5, \"name\": \"Sarah\"\n");
        writer.write("{\"id\": 5, \"name\": \"John\"\n");
        writer.write("{\"id\": 9, \"name\": \"Mical\"\n");
        writer.write("{\"id\": 5, \"name\": \"Mary\"\n");
        writer.write("{\"id\": 9, \"name\": \"Jimmy\"\n");
        writer.write("{\"id\": 5, \"name\": \"Tom\"\n");
        writer.write("{\"id\": 0, \"name\": \"Neil\"\n");
        writer.write("{\"id\": 5, \"name\": \"Rose\"\n");
        writer.write("{\"id\": 5, \"name\": \"Gobnait\"\n");
        writer.write("{\"id\": 1, \"name\": \"Rory\"\n");
        writer.write("{\"id\": 11, \"name\": \"Martin\"\n");
        writer.write("{\"id\": 5, \"name\": \"Trillian\"\n");
        writer.write("{\"id\": 5, \"name\": \"Emma\"\n");
        writer.write("{\"id\": 9, \"name\": \"Emily\"\n");
        writer.write("{\"id\": 5, \"name\": \"Sarah\"\n");
        writer.write("{\"id\": 5, \"name\": \"John\"\n");
        writer.write("{\"id\": 9, \"name\": \"Mical\"\n");
        writer.write("{\"id\": 5, \"name\": \"Mary\"\n");
        writer.write("{\"id\": 9, \"name\": \"Jimmy\"\n");
        writer.write("{\"id\": 5, \"name\": \"Tom\"\n");
        writer.write("{\"id\": 0, \"name\": \"Neil\"\n");
        writer.write("{\"id\": 5, \"name\": \"Rose\"\n");
        writer.write("{\"id\": 5, \"name\": \"Gobnait\"\n");
        writer.write("{\"id\": 1, \"name\": \"Rory\"\n");
        writer.write("{\"id\": 11, \"name\": \"Martin\"\n");
    }
}
Also used : LocalFsFileInputFactory(io.crate.execution.engine.collect.files.LocalFsFileInputFactory) InputFactory(io.crate.expression.InputFactory) NodeContext(io.crate.metadata.NodeContext) FileOutputStream(java.io.FileOutputStream) Functions(io.crate.metadata.Functions) OutputStreamWriter(java.io.OutputStreamWriter) Setup(org.openjdk.jmh.annotations.Setup)

Example 98 with Setup

use of org.openjdk.jmh.annotations.Setup in project crate by crate.

the class RowsBatchIteratorBenchmark method setup.

@Setup
public void setup() {
    rows = IntStream.range(0, 10_000_000).mapToObj(i -> new RowN(i)).collect(Collectors.toList());
    Functions functions = new ModulesBuilder().add(new ExtraFunctionsModule()).createInjector().getInstance(Functions.class);
    lastValueIntFunction = (WindowFunction) functions.getQualified(Signature.window(LAST_VALUE_NAME, parseTypeSignature("E"), parseTypeSignature("E")).withTypeVariableConstraints(typeVariable("E")), List.of(DataTypes.INTEGER), DataTypes.INTEGER);
}
Also used : ExtraFunctionsModule(io.crate.module.ExtraFunctionsModule) RowN(io.crate.data.RowN) Functions(io.crate.metadata.Functions) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) Setup(org.openjdk.jmh.annotations.Setup)

Example 99 with Setup

use of org.openjdk.jmh.annotations.Setup in project druid by druid-io.

the class BasicAuthUserMapSerdeBenchmark method setup.

@Setup
public void setup() throws IOException {
    smileMapper = new ObjectMapper(new SmileFactory());
    userMap = new HashMap<>();
    for (int i = 0; i < numUsers; i++) {
        BenchmarkUser user = makeUser();
        userMap.put(user.getName(), user);
    }
    serializedUsers = new ArrayList<>();
    for (BenchmarkUser user : userMap.values()) {
        byte[] serializedUser = smileMapper.writeValueAsBytes(user);
        serializedUsers.add(serializedUser);
    }
}
Also used : SmileFactory(com.fasterxml.jackson.dataformat.smile.SmileFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Setup(org.openjdk.jmh.annotations.Setup)

Example 100 with Setup

use of org.openjdk.jmh.annotations.Setup in project hive by apache.

the class ColumnarStorageBench method prepareBenchmark.

/**
 * Initializes resources that will be needed for each of the benchmark tests.
 *
 * @throws SerDeException If it cannot initialize the desired test format.
 * @throws IOException If it cannot write data to temporary files.
 */
@Setup(Level.Trial)
public void prepareBenchmark() throws SerDeException, IOException {
    if (format.equalsIgnoreCase("parquet") || format.equalsIgnoreCase("parquet-vec")) {
        storageFormatTest = new ParquetStorageFormatTest();
    } else if (format.equalsIgnoreCase("orc")) {
        storageFormatTest = new OrcStorageFormatTest();
    } else {
        throw new IllegalArgumentException("Invalid file format argument: " + format);
    }
    for (int i = 0; i < rows.length; i++) {
        recordWritable[i] = storageFormatTest.serialize(rows[i], oi);
    }
    fs = FileSystem.getLocal(new Configuration());
    writeFile = createTempFile();
    writePath = new Path(writeFile.getPath());
    readFile = createTempFile();
    readPath = new Path(readFile.getPath());
    /*
     * Write a bunch of random rows that will be used for read benchmark.
     */
    RecordWriter writer = storageFormatTest.getRecordWriter(readPath);
    storageFormatTest.writeRecords(writer, recordWritable);
    writer.close(false);
}
Also used : Path(org.apache.hadoop.fs.Path) RecordWriter(org.apache.hadoop.hive.ql.exec.FileSinkOperator.RecordWriter) Configuration(org.apache.hadoop.conf.Configuration) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

Setup (org.openjdk.jmh.annotations.Setup)303 Random (java.util.Random)62 File (java.io.File)33 ArrayList (java.util.ArrayList)24 InputRow (io.druid.data.input.InputRow)15 BenchmarkDataGenerator (io.druid.benchmark.datagen.BenchmarkDataGenerator)14 HyperUniquesSerde (io.druid.query.aggregation.hyperloglog.HyperUniquesSerde)14 HyperUniquesSerde (org.apache.druid.query.aggregation.hyperloglog.HyperUniquesSerde)14 DataGenerator (org.apache.druid.segment.generator.DataGenerator)14 Scope (org.openjdk.jmh.annotations.Scope)14 State (org.openjdk.jmh.annotations.State)14 DataSegment (org.apache.druid.timeline.DataSegment)13 Benchmark (org.openjdk.jmh.annotations.Benchmark)13 ByteBuffer (java.nio.ByteBuffer)12 IOException (java.io.IOException)11 IndexSpec (io.druid.segment.IndexSpec)10 List (java.util.List)10 TopicPartition (org.apache.kafka.common.TopicPartition)10 TimeUnit (java.util.concurrent.TimeUnit)9 LinearShardSpec (org.apache.druid.timeline.partition.LinearShardSpec)9