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


The following commit(s) were added to refs/heads/849-benchmarking by this push:
     new f4aac3d3 Add benchmark for geoparquet reader
f4aac3d3 is described below

commit f4aac3d399b4ad41c20882ef86c64a473314c359
Author: Bertil Chapuis <[email protected]>
AuthorDate: Wed Jun 12 17:23:22 2024 +0200

    Add benchmark for geoparquet reader
---
 .../benchmarking/GeoParquetReaderBenchmark.java    | 88 ++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git 
a/baremaps-benchmarking/src/main/java/org/apache/baremaps/benchmarking/GeoParquetReaderBenchmark.java
 
b/baremaps-benchmarking/src/main/java/org/apache/baremaps/benchmarking/GeoParquetReaderBenchmark.java
new file mode 100644
index 00000000..cd0f15b9
--- /dev/null
+++ 
b/baremaps-benchmarking/src/main/java/org/apache/baremaps/benchmarking/GeoParquetReaderBenchmark.java
@@ -0,0 +1,88 @@
+/*
+ * 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.baremaps.benchmarking;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+import org.apache.baremaps.geoparquet.GeoParquetReader;
+import org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider;
+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 software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.model.GetObjectRequest;
+import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
+
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
+@State(Scope.Benchmark)
+@Warmup(iterations = 0)
+@Measurement(iterations = 1)
+public class GeoParquetReaderBenchmark {
+
+    private static Path directory = Path.of("baremaps-benchmarks/data");
+
+    public static void main(String[] args) throws RunnerException {
+        Options opt = new OptionsBuilder()
+                .include(GeoParquetReaderBenchmark.class.getSimpleName())
+                .forks(1)
+                .build();
+        new Runner(opt).run();
+    }
+
+    @Setup
+    public void setup() throws IOException {
+        if (!Files.exists(directory)) {
+            try (var client = S3Client.builder()
+                    .region(Region.US_EAST_1)
+                    .credentialsProvider(new AnonymousAWSCredentialsProvider())
+                    .build()) {
+                var listRequest = ListObjectsV2Request.builder()
+                        .bucket("overturemaps-us-west-2")
+                        
.prefix("release/2024-03-12-alpha.0/theme=admins/type=locality_area/")
+                        .build();
+                var objects = client.listObjectsV2(listRequest).contents();
+                for (var object : objects) {
+                    var key = object.key();
+                    var name = key.substring(key.lastIndexOf("/") + 1);
+                    var file = directory.resolve(name);
+                    Files.createDirectories(file.getParent());
+                    if (!Files.exists(file)) {
+                        var getRequest = GetObjectRequest.builder()
+                                .bucket("overturemaps-us-west-2")
+                                .key(key)
+                                .build();
+                        client.getObject(getRequest, file);
+                    }
+                }
+            }
+        }
+    }
+
+    @Benchmark
+    public void read() {
+        GeoParquetReader reader = new GeoParquetReader(directory.toUri());
+        reader.readParallel().count();
+    }
+
+}

Reply via email to