romseygeek commented on code in PR #16166: URL: https://github.com/apache/lucene/pull/16166#discussion_r3349986411
########## lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/SortedNumericDocValuesRangeQueryBenchmark.java: ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.lucene.benchmark.jmh; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Random; +import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; +import org.apache.lucene.document.SortedNumericDocValuesField; +import org.apache.lucene.index.DirectoryReader; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.IndexWriterConfig; +import org.apache.lucene.search.BooleanClause.Occur; +import org.apache.lucene.search.BooleanQuery; +import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.Query; +import org.apache.lucene.store.Directory; +import org.apache.lucene.store.MMapDirectory; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; + +/** Benchmarks skip-indexed sorted-numeric doc values range queries. */ +@State(Scope.Thread) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@Warmup(iterations = 3, time = 3) +@Measurement(iterations = 5, time = 5) +@Fork(value = 1, warmups = 1) +public class SortedNumericDocValuesRangeQueryBenchmark { + + private static final String CLUSTERED = "clustered"; + private static final String MIXED = "mixed"; + private static final String RANDOM = "random"; + private static final String DENSE = "dense"; + private static final String SPARSE = "sparse"; + private static final String FIXED = "fixed"; + private static final String VARIABLE = "variable"; + private static final String PLAIN = "plain"; + private static final String CONJUNCTION = "conjunction"; + private static final long VALUE_SPACE = 1_000_000L; + + private Directory dir; + private IndexReader reader; + private Path path; + private Query query; + + @State(Scope.Benchmark) + public static class Params { + @Param({"1000000"}) + public int docCount; + + @Param({CLUSTERED, MIXED, RANDOM}) + public String dataPattern; + + @Param({"2", "4", "8"}) + public int valuesPerDoc; + + @Param({FIXED, VARIABLE}) + public String cardinality; + + @Param({DENSE, SPARSE}) + public String density; + + @Param({"0.01", "0.1", "0.5"}) + public double selectivity; + + @Param({PLAIN, CONJUNCTION}) + public String queryShape; + } + + @Setup(Level.Trial) + public void setup(Params params) throws Exception { + path = Files.createTempDirectory("sortedNumericRangeBench"); + dir = MMapDirectory.open(path); + + IndexWriterConfig iwc = new IndexWriterConfig(); + IndexWriter writer = new IndexWriter(dir, iwc); + Random random = new Random(42); + long[] values = new long[params.valuesPerDoc]; + + for (int docID = 0; docID < params.docCount; docID++) { + org.apache.lucene.document.Document doc = new org.apache.lucene.document.Document(); Review Comment: nit: use an import for this -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
