chore: import upstream snapshot with attribution
bazel / bazel.ubuntu-latest (push) Failing after 1s
build-and-test-perfcounters / ubuntu-latest.Debug (push) Failing after 0s
build-and-test-perfcounters / ubuntu-latest.Release (push) Failing after 1s
doxygen / Build HTML documentation (push) Failing after 1s
python + Bazel pre-commit checks / pre-commit (push) Failing after 1s
sanitizer / tsan.Debug (push) Failing after 1s
sanitizer / ubsan.Debug (push) Failing after 0s
sanitizer / ubsan.RelWithDebInfo (push) Failing after 1s
build-and-test-min-cmake / ubuntu-latest.min-cmake (push) Failing after 1s
clang-format-lint / check-clang-format (push) Failing after 1s
sanitizer / asan.Debug (push) Failing after 1s
sanitizer / msan.RelWithDebInfo (push) Failing after 1s
clang-tidy / run-clang-tidy (push) Failing after 1s
sanitizer / msan.Debug (push) Failing after 1s
sanitizer / asan.RelWithDebInfo (push) Failing after 0s
sanitizer / tsan.RelWithDebInfo (push) Failing after 0s
test-bindings / Test Rust bindings on ubuntu-latest (push) Failing after 0s
test-bindings / Test Python 3.10 bindings on ubuntu-latest (push) Failing after 0s
test-bindings / Test Python 3.11 bindings on ubuntu-latest (push) Failing after 0s
test-bindings / Test Python 3.12 bindings on ubuntu-latest (push) Failing after 1s
test-bindings / Test Python 3.13 bindings on ubuntu-latest (push) Failing after 0s
build-and-test / macos-latest.Debug.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Debug.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Debug.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Debug.shared.clang++ (push) Has been cancelled
bazel / bazel.macos-latest (push) Has been cancelled
bazel / bazel.windows-latest (push) Has been cancelled
build-and-test-min-cmake / macos-latest.min-cmake (push) Has been cancelled
build-and-test / ubuntu-22.04.Debug.static.clang++ (push) Has been cancelled
build-and-test / macos-latest.Debug.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Debug.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Debug.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Debug.shared.g++ (push) Has been cancelled
build-and-test / macos-latest.Debug.static.g++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Debug.static.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Debug.static.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Debug.static.g++ (push) Has been cancelled
build-and-test / macos-latest.Release.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Release.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Release.shared.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Release.shared.clang++ (push) Has been cancelled
build-and-test / macos-latest.Release.static.clang++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Release.static.clang++ (push) Has been cancelled
build-and-test / macos-latest.Debug.static.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Debug.static.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Debug.static.clang++ (push) Has been cancelled
build-and-test / macos-latest.Release.static.g++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Release.static.g++ (push) Has been cancelled
build-and-test / windows-2025.Debug.static.VS-18-2025 (push) Has been cancelled
build-and-test / windows-2022.Release.shared.VS-17-2022 (push) Has been cancelled
build-and-test / windows-2022.Release.static.VS-17-2022 (push) Has been cancelled
build-and-test / windows-2025.Release.shared.VS-18-2025 (push) Has been cancelled
build-and-test / windows-2025.Release.static.VS-18-2025 (push) Has been cancelled
build-and-test / windows-latest.Debug.shared.CLANG64 (push) Has been cancelled
build-and-test / windows-latest.Debug.shared.MINGW64 (push) Has been cancelled
build-and-test / windows-latest.Debug.shared.UCRT64 (push) Has been cancelled
build-and-test / windows-latest.Debug.static.CLANG64 (push) Has been cancelled
build-and-test / windows-latest.Debug.static.MINGW64 (push) Has been cancelled
build-and-test / windows-latest.Debug.static.UCRT64 (push) Has been cancelled
build-and-test / ubuntu-24.04.Release.static.clang++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Release.static.clang++ (push) Has been cancelled
build-and-test / macos-latest.Release.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-22.04.Release.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Release.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Release.shared.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04.Release.static.g++ (push) Has been cancelled
build-and-test / ubuntu-24.04-arm.Release.static.g++ (push) Has been cancelled
build-and-test / windows-2022.Debug.shared.VS-17-2022 (push) Has been cancelled
build-and-test / windows-2022.Debug.static.VS-17-2022 (push) Has been cancelled
build-and-test / windows-2025.Debug.shared.VS-18-2025 (push) Has been cancelled
build-and-test / windows-latest.Release.static.MINGW64 (push) Has been cancelled
build-and-test / windows-latest.Release.static.UCRT64 (push) Has been cancelled
test-bindings / Test Python 3.10 bindings on macos-latest (push) Has been cancelled
test-bindings / Test Python 3.11 bindings on macos-latest (push) Has been cancelled
test-bindings / Test Python 3.12 bindings on macos-latest (push) Has been cancelled
test-bindings / Test Python 3.13 bindings on macos-latest (push) Has been cancelled
build-and-test / windows-latest.Release.shared.CLANG64 (push) Has been cancelled
build-and-test / windows-latest.Release.shared.MINGW64 (push) Has been cancelled
build-and-test / windows-latest.Release.shared.UCRT64 (push) Has been cancelled
build-and-test / windows-latest.Release.static.CLANG64 (push) Has been cancelled
test-bindings / Test Python 3.12 bindings on windows-latest (push) Has been cancelled
test-bindings / Test Python 3.13 bindings on windows-latest (push) Has been cancelled
test-bindings / Test Python 3.10 bindings on windows-latest (push) Has been cancelled
test-bindings / Test Python 3.11 bindings on windows-latest (push) Has been cancelled
test-bindings / Test Rust bindings on macos-latest (push) Has been cancelled
test-bindings / Test Rust bindings on windows-latest (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:28:34 +08:00
commit cb66c5d68e
221 changed files with 30725 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#[cxx::bridge]
pub mod ffi {
#[namespace = "benchmark"]
unsafe extern "C++" {
include!("benchmark/benchmark.h");
type State;
fn KeepRunning(self: Pin<&mut State>) -> bool;
fn RunSpecifiedBenchmarks() -> usize;
}
#[namespace = "benchmark::rust_api"]
unsafe extern "C++" {
include!("rust_api.h");
unsafe fn SkipWithError(state: Pin<&mut State>, msg: &str);
unsafe fn RegisterBenchmark(name: &str, func: fn(Pin<&mut State>));
unsafe fn Initialize(argc: *mut i32, argv: usize);
}
}
+66
View File
@@ -0,0 +1,66 @@
pub mod ffi;
use std::ffi::CString;
use std::os::raw::c_char;
use std::pin::Pin;
pub struct State<'a> {
#[doc(hidden)]
pub inner: Pin<&'a mut ffi::ffi::State>,
}
impl<'a> State<'a> {
/// Returns true if the benchmark should continue running.
///
/// **Note:** `keep_running()` currently has a small per-iteration overhead due to the FFI boundary.
/// In the future, this could be optimized using `KeepRunningBatch` under the hood.
#[inline]
pub fn keep_running(&mut self) -> bool {
self.inner.as_mut().KeepRunning()
}
pub fn skip_with_error(&mut self, msg: &str) {
unsafe {
ffi::ffi::SkipWithError(self.inner.as_mut(), msg);
}
}
}
/// Initialize the benchmark library.
/// This should be called before `run_specified_benchmarks`.
pub fn initialize(args: &Vec<String>) {
let mut c_args: Vec<CString> = args.iter()
.map(|arg| CString::new(arg.as_str()).unwrap())
.collect();
let mut c_ptrs: Vec<*mut c_char> = c_args.iter_mut()
.map(|c| c.as_ptr() as *mut c_char)
.collect();
let mut argc = c_ptrs.len() as i32;
let argv = c_ptrs.as_mut_ptr();
unsafe {
ffi::ffi::Initialize(&mut argc as *mut _, argv as usize);
}
}
#[macro_export]
macro_rules! register_benchmark {
($name:expr, $func:path) => {
{
fn trampoline(mut state: std::pin::Pin<&mut $crate::ffi::ffi::State>) {
let mut wrapped = $crate::State { inner: state.as_mut() };
$func(&mut wrapped);
}
unsafe {
$crate::ffi::ffi::RegisterBenchmark($name, trampoline);
}
}
};
}
/// Run all registered benchmarks.
pub fn run_specified_benchmarks() -> usize {
ffi::ffi::RunSpecifiedBenchmarks()
}
+33
View File
@@ -0,0 +1,33 @@
#include "rust_api.h"
#include <string>
namespace benchmark {
namespace rust_api {
void RegisterBenchmark(rust::Str name, rust::Fn<void(benchmark::State&)> func);
void Initialize(int* argc, size_t argv);
void SkipWithError(benchmark::State& state, rust::Str msg);
void RegisterBenchmark(rust::Str name, rust::Fn<void(benchmark::State&)> func) {
::benchmark::RegisterBenchmark(std::string(name).c_str(),
[func](benchmark::State& st) { func(st); });
}
void Initialize(int* argc, size_t argv) {
char** argv_ptr = reinterpret_cast<char**>(argv);
if (argc != nullptr && *argc > 0 && argv_ptr != nullptr &&
argv_ptr[0] != nullptr) {
static std::string executable_name;
executable_name = argv_ptr[0];
argv_ptr[0] = executable_name.data();
}
::benchmark::Initialize(argc, argv_ptr);
}
void SkipWithError(benchmark::State& state, rust::Str msg) {
state.SkipWithError(std::string(msg).c_str());
}
} // namespace rust_api
} // namespace benchmark
+14
View File
@@ -0,0 +1,14 @@
#pragma once
#include "benchmark/benchmark.h"
#include "rust/cxx.h"
namespace benchmark {
namespace rust_api {
void RegisterBenchmark(rust::Str name, rust::Fn<void(benchmark::State&)> func);
void Initialize(int* argc, size_t argv);
void SkipWithError(benchmark::State& state, rust::Str msg);
} // namespace rust_api
} // namespace benchmark