This is an automated email from the ASF dual-hosted git repository. bchapuis pushed a commit to branch 849-benchmarking in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
commit 021edd90832a2c309982addac6c7846d746fa65f Author: Bertil Chapuis <[email protected]> AuthorDate: Wed Jun 12 17:53:06 2024 +0200 Add benchmarks --- .gitignore | 3 ++ .../baremaps/benchmarking/SmallFileBenchmark.java | 49 ++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/.gitignore b/.gitignore index a66d0430..15b5788b 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,9 @@ examples/openstreetmap/tiles/ examples/transformation/*.pbf +# Benchmarking +baremaps-benchmarking/small/ + # Docs .jekyll-cache/ _site/ diff --git a/baremaps-benchmarking/src/main/java/org/apache/baremaps/benchmarking/SmallFileBenchmark.java b/baremaps-benchmarking/src/main/java/org/apache/baremaps/benchmarking/SmallFileBenchmark.java new file mode 100644 index 00000000..91a3ac46 --- /dev/null +++ b/baremaps-benchmarking/src/main/java/org/apache/baremaps/benchmarking/SmallFileBenchmark.java @@ -0,0 +1,49 @@ +package org.apache.baremaps.benchmarking; + +import org.apache.baremaps.geoparquet.GeoParquetReader; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@State(Scope.Benchmark) +@Warmup(iterations = 0) +@Measurement(iterations = 1) +public class SmallFileBenchmark { + + private Path source = Path.of("baremaps-testing/data/samples/example.parquet").toAbsolutePath(); + private Path directory = Path.of("baremaps-benchmarking/small").toAbsolutePath(); + + public static void main(String[] args) throws RunnerException, IOException { + Options opt = new OptionsBuilder() + .include(SmallFileBenchmark.class.getSimpleName()) + .forks(1) + .build(); + new Runner(opt).run(); + } + + @Setup + public void setup() throws IOException { + if (!Files.exists(directory)) { + for (int i = 0; i < 1000; i++) { + Path target = directory.resolve(i + ".parquet"); + Files.createDirectories(target.getParent()); + Files.copy(source, target); + } + } + } + + @Benchmark + public void read() { + GeoParquetReader reader = new GeoParquetReader(directory.toUri()); + reader.readParallel().count(); + } +}
