summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Moritz <chrmoritz@users.noreply.github.com>2019-10-06 17:18:15 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-10-06 11:18:15 -0400
commit3e02d7ddbc04cf3bfc681a5f4cfe6b91a9860cbd (patch)
tree5ec3a415d8f13e784f74d593680c02c5fca8a9a8
parentbed7034fc44a8d20e11a85b6092e7f0f34f43ff8 (diff)
refactor benchmark results posting (#3076)
-rw-r--r--.github/workflows/build.yml7
-rwxr-xr-xtools/benchmark.py25
-rwxr-xr-xtools/build_benchmark_jsons.py20
3 files changed, 24 insertions, 28 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c6e526b2c..b1d873741 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -115,16 +115,15 @@ jobs:
env:
DENOBOT_PAT: ${{ secrets.DENOBOT_PAT }}
run: |
- # Note gh-pages branch is cloned into //gh-pages/ by
- # tools/benchmark.py, hence the following copy is ok:
+ git clone --depth 1 -b gh-pages https://${DENOBOT_PAT}@github.com/denoland/deno.git gh-pages
+ python ./tools/build_benchmark_jsons.py
cp -r website/* gh-pages/
cd gh-pages
- git remote add origin2 https://${DENOBOT_PAT}@github.com/denoland/deno.git
git config user.email "propelml@gmail.com"
git config user.name "denobot"
git add .
git commit --message "Update benchmarks"
- git push origin2 gh-pages
+ git push origin gh-pages
- name: Worker info
if: matrix.kind == 'bench'
diff --git a/tools/benchmark.py b/tools/benchmark.py
index 7d812daf3..85e126b88 100755
--- a/tools/benchmark.py
+++ b/tools/benchmark.py
@@ -10,7 +10,6 @@ import os
import sys
import json
import time
-import shutil
import tempfile
import subprocess
from util import build_path, executable_suffix, root_path, run, run_output
@@ -30,10 +29,6 @@ exec_time_benchmarks = [
("workers_round_robin", ["tests/workers_round_robin_bench.ts"]),
]
-gh_pages_data_file = "gh-pages/data.json"
-all_data_file = "website/data.json" # Includes all benchmark data.
-recent_data_file = "website/recent.json" # Includes recent 20 benchmark data.
-
def read_json(filename):
with open(filename) as json_file:
@@ -45,19 +40,6 @@ def write_json(filename, data):
json.dump(data, outfile)
-def import_data_from_gh_pages():
- if os.path.exists(all_data_file):
- return
- try:
- run([
- "git", "clone", "--depth", "1", "-b", "gh-pages",
- "https://github.com/denoland/deno.git", "gh-pages"
- ])
- shutil.copy(gh_pages_data_file, all_data_file)
- except ValueError:
- write_json(all_data_file, []) # writes empty json data
-
-
def get_binary_sizes(build_dir):
sizes = {}
mtimes = {}
@@ -246,7 +228,6 @@ def main(argv):
deno_exe = os.path.join(build_dir, "deno")
os.chdir(root_path)
- import_data_from_gh_pages()
new_data = {
"created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"),
@@ -275,11 +256,7 @@ def main(argv):
print json.dumps(new_data, indent=2)
print "===== </BENCHMARK RESULTS>"
- all_data = read_json(all_data_file)
- all_data.append(new_data)
-
- write_json(all_data_file, all_data)
- write_json(recent_data_file, all_data[-20:])
+ write_json(os.path.join(build_dir, "bench.json"), new_data)
if __name__ == '__main__':
diff --git a/tools/build_benchmark_jsons.py b/tools/build_benchmark_jsons.py
new file mode 100755
index 000000000..1d7a03401
--- /dev/null
+++ b/tools/build_benchmark_jsons.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+from util import build_path
+from benchmark import read_json, write_json
+import os
+
+current_data_file = os.path.join(build_path(), "bench.json")
+gh_pages_data_file = "gh-pages/data.json"
+all_data_file = "website/data.json" # Includes all benchmark data.
+recent_data_file = "website/recent.json" # Includes recent 20 benchmark data.
+
+assert os.path.exists(current_data_file)
+assert os.path.exists(gh_pages_data_file)
+
+new_data = read_json(current_data_file)
+all_data = read_json(gh_pages_data_file)
+all_data.append(new_data)
+
+write_json(all_data_file, all_data)
+write_json(recent_data_file, all_data[-20:])