Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CodSpeed

on:
push:
branches: [master, opencc-wasm-develop]
pull_request:
branches: [master, opencc-wasm-develop]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
repository-cache: true

- name: Configure BuildBuddy
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
shell: bash
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
run: |
if [ -n "${BUILDBUDDY_API_KEY}" ]; then
{
echo "build --config=buildbuddy"
echo "build --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}"
echo "build --bes_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}"
} >> .bazelrc.user
echo "BuildBuddy enabled."
else
echo "BUILDBUDDY_API_KEY not set; skipping BuildBuddy config."
fi

- name: Build benchmark
run: >-
bazel build
--@codspeed_google_benchmark_compat//:codspeed_mode=simulation
--compilation_mode=dbg
--copt=-O2
--copt=-DNDEBUG
//src/benchmark:performance

- name: Prepare temp directory
run: mkdir -p /tmp/opencc_bench_temp

- uses: CodSpeedHQ/action@v3
with:
token: ${{ secrets.CODSPEED_TOKEN_FRANKSLIN }}
run: >-
OPENCC_BENCHMARK_TEMP_DIR=/tmp/opencc_bench_temp
bazel-bin/src/benchmark/performance
'--benchmark_filter=BM_ConvertLongText.*ocd2'
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module(

bazel_dep(name = "aspect_bazel_lib", version = "2.22.5")
bazel_dep(name = "aspect_rules_js", version = "3.2.2")
bazel_dep(name = "codspeed_google_benchmark_compat", version = "2.1.0", dev_dependency = True)
bazel_dep(name = "darts-clone", version = "0.32")
bazel_dep(name = "googletest", version = "1.17.0.bcr.2", dev_dependency = True)
bazel_dep(name = "marisa-trie", version = "0.3.1.bcr.2")
Expand Down
6 changes: 6 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/benchmark/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")

package(default_visibility = ["//visibility:public"])

cc_binary(
name = "performance",
testonly = True,
srcs = ["Performance.cpp"],
includes = [".."],
deps = [
"@codspeed_google_benchmark_compat//:benchmark",
"//deps/rapidjson-1.1.0:rapidjson",
"//src:exception_lib",
"//src:simple_converter_lib",
"//src:test_utils_utf8_lib",
"@bazel_tools//tools/cpp/runfiles",
],
data = [
"//data/config:config",
"//data/dictionary:CJK_Compatibility_Ideographs.txt",
"//data/dictionary:binary_dictionaries",
"//data/dictionary:text_dictionaries",
"//src/tools:command_line",
"//test/benchmark:benchmark_data",
],
)
Loading
Loading