You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/21 17:40:07 UTC

[GitHub] [arrow] alistaire47 commented on a diff in pull request #14148: ARROW-17751: [Go][Benchmarking] Add Go Benchmark Script

alistaire47 commented on code in PR #14148:
URL: https://github.com/apache/arrow/pull/14148#discussion_r1002029791


##########
.github/workflows/go.yml:
##########
@@ -183,13 +192,13 @@ jobs:
         run: ci/scripts/go_build.sh $(pwd)
       - name: Test
         shell: bash
-        run: ci/scripts/go_test.sh $(pwd)
+        run: ci/scripts/go_test.sh $(pwd)      

Review Comment:
   ```suggestion
           run: ci/scripts/go_test.sh $(pwd)
   ```
   Maybe try saving with "strip trailing whitespace"? Just trying to prevent future whitespace diffs



##########
ci/scripts/go_bench_adapt.py:
##########
@@ -0,0 +1,90 @@
+# 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.
+
+import json
+import os
+import uuid
+import logging
+from pathlib import Path
+from typing import List
+
+from benchadapt import BenchmarkResult
+from benchadapt.adapters import BenchmarkAdapter
+from benchadapt.log import log
+
+log.setLevel(logging.DEBUG)
+
+ARROW_ROOT = Path(__file__).parent.parent.parent.resolve()
+SCRIPTS_PATH = ARROW_ROOT / "ci" / "scripts"
+
+class GoAdapter(BenchmarkAdapter):
+    result_file = "bench_stats.json"
+    command = ["bash", SCRIPTS_PATH / "go_bench.sh", ARROW_ROOT, "-json"]
+
+    def __init__(self, *args, **kwargs) -> None:
+        super().__init__(command=self.command, *args, **kwargs)
+
+    def _transform_results(self) -> List[BenchmarkResult]:
+        with open(self.result_file, "r") as f:
+            raw_results = json.load(f)
+
+        run_id = uuid.uuid4().hex        
+        parsed_results = []
+        for suite in raw_results[0]["Suites"]:
+            batch_id = uuid.uuid4().hex
+            pkg = suite["Pkg"]
+
+            for benchmark in suite["Benchmarks"]:
+                data = benchmark["Mem"]["MBPerSec"] * 1e6
+                time = 1 / benchmark["NsPerOp"] * 1e9
+
+                name = benchmark["Name"].removeprefix('Benchmark')
+                ncpu = name[name.rfind('-')+1:]
+                pieces = name[:-(len(ncpu)+1)].split('/')                
+
+                parsed = BenchmarkResult(                    
+                    run_id=run_id,
+                    batch_id=batch_id,
+                    stats={
+                        "data": [data],
+                        "unit": "b/s",
+                        "times": [time],
+                        "time_unit": "i/s",
+                        "iterations": benchmark["Runs"],
+                    },
+                    context={
+                        "benchmark_language": "Go",
+                        "goos": suite["Goos"],
+                        "goarch": suite["Goarch"],
+                    },
+                    tags={
+                        "pkg": pkg,
+                        "num_cpu": ncpu,
+                        "name": pieces[0],
+                        "params": '/'.join(pieces[1:]),
+                    },
+                    run_reason=f'commit',

Review Comment:
   Is this only going to run on master? If so, this is fine; if not, it needs to be flipped from gh actions



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org