Skip to content

Commit

Permalink
Run JS and Wasm benchmarks with SpiderMonkey as well.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 704725513
  • Loading branch information
gkdn authored and copybara-github committed Dec 10, 2024
1 parent 9f61ed3 commit a715720
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 8 additions & 4 deletions benchmarking/java/com/google/j2cl/benchmarking/benchmarks.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def benchmark(name, deps = []):
entry_points = ["%s_launcher" % name],
)

_d8_benchmark(
_jsvm_benchmark(
name = "%s_local-j2cl" % name,
data = [":%s_j2cl_entry.js" % name],
tags = ["j2cl"],
Expand Down Expand Up @@ -102,7 +102,7 @@ def benchmark(name, deps = []):
entry_points = ["%s_launcher" % name],
)

_d8_benchmark(
_jsvm_benchmark(
name = "%s_local-j2wasm" % name,
data = [
":%s_j2wasm_entry.js" % name,
Expand All @@ -127,11 +127,15 @@ def gen_benchmark_suite(name):
],
)

def _d8_benchmark(name, data, tags):
def _jsvm_benchmark(name, data, tags):
_jsvm_benchmark_impl(name + "-v8", "v8 --expose-gc --experimental-wasm-imported-strings --turboshaft-future", data, tags)
_jsvm_benchmark_impl(name + "-sm", "sm -P wasm_js_string_builtins -f", data, tags)

def _jsvm_benchmark_impl(name, cmd, data, tags):
native.genrule(
name = "gen_%s_sh" % name,
cmd = "echo cd $$(dirname $(location %s)) '&&' " % data[0] +
"v8 --expose-gc --experimental-wasm-imported-strings --turboshaft-future" +
cmd +
" $$(basename $(location %s)) > $@" % data[0] +
" -e \\''const results = JSON.parse(execute())'\\'" +
" -e \\''console.log(results.reduce((a, b) => a + b) / results.length)'\\' ",
Expand Down
10 changes: 6 additions & 4 deletions dev/repo_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
TEST_LIST = INTEGRATION_ROOT + "optimized_js_list.bzl"
BENCH_ROOT = "benchmarking/java/com/google/j2cl/benchmarks/"
JVM_BENCH_PATTERN = BENCH_ROOT + "%s"
J2CL_BENCH_PATTERN = BENCH_ROOT + "%s-j2cl"
J2WASM_BENCH_PATTERN = BENCH_ROOT + "%s-j2wasm"
J2CL_BENCH_PATTERN = BENCH_ROOT + "%s-j2cl-%s"
J2WASM_BENCH_PATTERN = BENCH_ROOT + "%s-j2wasm-%s"
BLAZE_CMD = "bazel"
BIN_DIR = BLAZE_CMD + "-bin/"

Expand All @@ -39,9 +39,11 @@ def get_benchmarks(bench_name, platforms):
if "JVM" in platforms:
benchmarks["JVM"] = JVM_BENCH_PATTERN % bench_name
if "CLOSURE" in platforms:
benchmarks["J2CL"] = J2CL_BENCH_PATTERN % bench_name
benchmarks["JS_V8"] = J2CL_BENCH_PATTERN % (bench_name, "v8")
benchmarks["JS_SM"] = J2CL_BENCH_PATTERN % (bench_name, "sm")
if "WASM" in platforms:
benchmarks["J2WASM"] = J2WASM_BENCH_PATTERN % bench_name
benchmarks["WASM_V8"] = J2WASM_BENCH_PATTERN % (bench_name, "v8")
benchmarks["WASM_SM"] = J2WASM_BENCH_PATTERN % (bench_name, "sm")
return benchmarks


Expand Down

0 comments on commit a715720

Please sign in to comment.