load("//:build/kj_test.bzl", "kj_test") load("//:build/wd_cc_benchmark.bzl", "wd_cc_benchmark") load("//:build/wd_cc_library.bzl", "wd_cc_library") load("//:build/wd_test.bzl", "wd_test") wd_cc_library( name = "bench-tools", hdrs = ["bench-tools.h"], defines = select({ "//src/workerd/server:really_use_tcmalloc": ["WD_USE_TCMALLOC"], "//conditions:default": [], }), # clang-tidy fails on this target when using clang-tidy-21 together with llvm-19 headers due to # changes in how intrinsics are defined - disable clang-tidy here until we start using LLVM 21 # everywhere. tags = [ "no-clang-tidy", "workerd-benchmark", ], visibility = ["//visibility:public"], deps = [ "@capnp-cpp//src/kj:kj-test", "@google_benchmark//:benchmark", ] + select({ # tcmalloc is only available on Linux and when use_tcmalloc is enabled. # We use the malloc_extension API to configure tcmalloc for deterministic benchmarks. "//src/workerd/server:really_use_tcmalloc": ["@tcmalloc//tcmalloc:malloc_extension"], "//conditions:default": [], }), ) wd_cc_library( name = "test-fixture", srcs = ["test-fixture.c++"], hdrs = ["test-fixture.h"], visibility = ["//visibility:public"], deps = [ "//src/workerd/io", "//src/workerd/jsg", "//src/workerd/server:workerd-api", "//src/workerd/util:autogate", ], ) kj_test( src = "test-fixture-test.c++", deps = [":test-fixture"], ) # Use `bazel run //src/workerd/tests:bench-json` to benchmark wd_cc_benchmark( name = "bench-json", srcs = ["bench-json.c++"], deps = [ "//src/workerd/api:r2-api_capnp", "@capnp-cpp//src/kj", ], ) wd_cc_benchmark( name = "bench-mimetype", srcs = ["bench-mimetype.c++"], deps = [ "//src/workerd/util:mimetype", ], ) wd_cc_benchmark( name = "bench-kj-headers", srcs = ["bench-kj-headers.c++"], deps = [ "@capnp-cpp//src/kj/compat:kj-http", ], ) wd_cc_benchmark( name = "bench-api-headers", srcs = ["bench-api-headers.c++"], deps = [ ":test-fixture", ], ) wd_cc_benchmark( name = "bench-global-scope", srcs = ["bench-global-scope.c++"], deps = [":test-fixture"], ) wd_cc_benchmark( name = "bench-regex", srcs = ["bench-regex.c++"], deps = [ ":test-fixture", "//src/workerd/util", ], ) wd_cc_benchmark( name = "bench-util", srcs = ["bench-util.c++"], deps = [ ":test-fixture", "//src/workerd/jsg", ], ) wd_cc_benchmark( name = "bench-text-encoder", srcs = ["bench-text-encoder.c++"], deps = [":test-fixture"], ) wd_cc_benchmark( name = "bench-response", srcs = ["bench-response.c++"], deps = [":test-fixture"], ) wd_cc_benchmark( name = "bench-jsstring", srcs = ["bench-jsstring.c++"], deps = [ ":test-fixture", "//src/workerd/jsg", ], ) # Benchmark for comparing stream piping implementations # Tagged manual because it takes too long for CI - run explicitly with: # bazel run //src/workerd/tests:bench-stream-piping wd_cc_benchmark( name = "bench-stream-piping", srcs = ["bench-stream-piping.c++"], tags = ["manual"], deps = [ ":test-fixture", "//src/workerd/io", "//src/workerd/jsg", ], ) # Benchmark for PumpToReader (ReadableStream::pumpTo path in standard.c++). # Run before and after DrainingReader adoption to measure improvement. # bazel run --config=opt //src/workerd/tests:bench-pumpto wd_cc_benchmark( name = "bench-pumpto", srcs = ["bench-pumpto.c++"], tags = ["manual"], deps = [ ":test-fixture", "//src/workerd/io", "//src/workerd/jsg", ], ) wd_test( src = "unknown-import-assertions-test.wd-test", args = ["--experimental"], data = ["unknown-import-assertions-test.js"], ) wd_test( src = "module-imports-test.wd-test", args = ["--experimental"], data = [ "module-imports-test.js", "test.wasm", ], lint = False, ) wd_test( src = "performance-test.wd-test", data = ["performance-test.js"], ) # REPRL tests using KJ test framework wd_cc_library( name = "libreprl", srcs = ["libreprl/libreprl.c"], hdrs = ["libreprl/libreprl.h"], copts = [ "-std=c23", ], ) kj_test( src = "test-reprl.c++", data = [ "//fuzzilli:config.capnp", "//fuzzilli:worker.js", "//src/workerd/server:workerd", ], tags = ["requires-fuzzilli"], deps = [ ":libreprl", "@bazel_tools//tools/cpp/runfiles", ], )