From 660b13a0456d75e038ac98669e56ea6621968b68 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 25 Jan 2026 17:24:58 +0300 Subject: [PATCH 1/8] ChaosBenches: Add Md4HasherCreateComputeDeleteBench --- CMakeLists.txt | 1 + ChaosBenches/CMakeLists.txt | 21 ++++++++++++++++++ ChaosBenches/Hash/Md4HasherBenches.cpp | 30 ++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 ChaosBenches/CMakeLists.txt create mode 100644 ChaosBenches/Hash/Md4HasherBenches.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ad3e34..c686d7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,3 +15,4 @@ target_include_directories(Chaos INTERFACE ) add_subdirectory(ChaosTests) +add_subdirectory(ChaosBenches) diff --git a/ChaosBenches/CMakeLists.txt b/ChaosBenches/CMakeLists.txt new file mode 100644 index 0000000..e058d00 --- /dev/null +++ b/ChaosBenches/CMakeLists.txt @@ -0,0 +1,21 @@ +include(FetchContent) + +cmake_policy(SET CMP0135 NEW) + +FetchContent_Declare( + googlebenchmark + URL https://github.com/google/benchmark/archive/refs/tags/v1.9.5.tar.gz + URL_HASH SHA256=9631341c82bac4a288bef951f8b26b41f69021794184ece969f8473977eaa340 +) + +set(BENCHMARK_ENABLE_WERROR OFF CACHE BOOL "" FORCE) +set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googlebenchmark) + +set(ChaosBenches_SOURCE Hash/Md4HasherBenches.cpp) + +add_executable(ChaosBenches ${ChaosBenches_SOURCE}) +target_link_libraries(ChaosBenches benchmark::benchmark) +target_include_directories(ChaosBenches PRIVATE + $ +) diff --git a/ChaosBenches/Hash/Md4HasherBenches.cpp b/ChaosBenches/Hash/Md4HasherBenches.cpp new file mode 100644 index 0000000..9c7a443 --- /dev/null +++ b/ChaosBenches/Hash/Md4HasherBenches.cpp @@ -0,0 +1,30 @@ +#include + +#include + +using namespace Chaos::Hash::Md4; + +static void Md4HasherCreateComputeDeleteBench(benchmark::State & state) +{ + const char * data + = "All states, all powers, that have held and hold rule over men have been and are either republics or principalities.\n" + "Principalities are either hereditary, in which the family has been long established; or they are new.\n" + "The new are either entirely new, as was Milan to Francesco Sforza, or they are, as it were, members annexed to the hereditary state of the " + "prince who has acquired them, as was the kingdom of Naples to that of the King of Spain.\n" + "Such dominions thus acquired are either accustomed to live under a prince, or to live in freedom; and are acquired either by the arms of the " + "prince himself, or of others, or else by fortune or by ability."; + const size_t dataLen = strlen(data); + + for (auto _ : state) + { + Md4Hasher hasher; + hasher.Update(data, data + dataLen); + Md4Hash result = hasher.Finish(); + + benchmark::DoNotOptimize(result); + } +} + +BENCHMARK(Md4HasherCreateComputeDeleteBench); + +BENCHMARK_MAIN(); From c0685d00b5986fe6fa86cedf9405238691c74d63 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 25 Jan 2026 17:30:50 +0300 Subject: [PATCH 2/8] Add ChaosBenchmarkCI.yaml workflow --- .gitea/workflows/ChaosBenchmarkCI.yaml | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .gitea/workflows/ChaosBenchmarkCI.yaml diff --git a/.gitea/workflows/ChaosBenchmarkCI.yaml b/.gitea/workflows/ChaosBenchmarkCI.yaml new file mode 100644 index 0000000..791b0c3 --- /dev/null +++ b/.gitea/workflows/ChaosBenchmarkCI.yaml @@ -0,0 +1,30 @@ +name: ChaosBenchmark CI + +on: [push, pull_request] + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake + + - name: Configure, build + run: | + mkdir build + cd build + cmake .. + cmake --build . + + - name: Run benchmarks + run: | + cd build + ./ChaosBenches/ChaosBenches \ No newline at end of file From 3e7a0f3e5302d570981820947f9d11174f1e0b58 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 25 Jan 2026 17:34:12 +0300 Subject: [PATCH 3/8] Fix benchmark job name --- .gitea/workflows/ChaosBenchmarkCI.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/ChaosBenchmarkCI.yaml b/.gitea/workflows/ChaosBenchmarkCI.yaml index 791b0c3..a1332e8 100644 --- a/.gitea/workflows/ChaosBenchmarkCI.yaml +++ b/.gitea/workflows/ChaosBenchmarkCI.yaml @@ -3,7 +3,7 @@ name: ChaosBenchmark CI on: [push, pull_request] jobs: - build-and-test: + build-and-benchmark: runs-on: ubuntu-latest steps: From ff57cd0d31a305614651dd67112bf07f7ceedd4b Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 25 Jan 2026 17:35:53 +0300 Subject: [PATCH 4/8] Fix #includes: Add for strlen() --- ChaosBenches/Hash/Md4HasherBenches.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ChaosBenches/Hash/Md4HasherBenches.cpp b/ChaosBenches/Hash/Md4HasherBenches.cpp index 9c7a443..b6fdbaf 100644 --- a/ChaosBenches/Hash/Md4HasherBenches.cpp +++ b/ChaosBenches/Hash/Md4HasherBenches.cpp @@ -1,4 +1,5 @@ #include +#include #include From 478012dd103420a304aa56d0593fd757d725c95e Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 25 Jan 2026 17:42:24 +0300 Subject: [PATCH 5/8] Place test and bench jobs in one .yaml --- .../{ChaosBenchmarkCI.yaml => ChaosCI.yaml} | 28 ++++++++++++++++- .gitea/workflows/ChaosTestCI.yaml | 30 ------------------- 2 files changed, 27 insertions(+), 31 deletions(-) rename .gitea/workflows/{ChaosBenchmarkCI.yaml => ChaosCI.yaml} (51%) delete mode 100644 .gitea/workflows/ChaosTestCI.yaml diff --git a/.gitea/workflows/ChaosBenchmarkCI.yaml b/.gitea/workflows/ChaosCI.yaml similarity index 51% rename from .gitea/workflows/ChaosBenchmarkCI.yaml rename to .gitea/workflows/ChaosCI.yaml index a1332e8..84eadd3 100644 --- a/.gitea/workflows/ChaosBenchmarkCI.yaml +++ b/.gitea/workflows/ChaosCI.yaml @@ -1,8 +1,34 @@ -name: ChaosBenchmark CI +name: Chaos CI on: [push, pull_request] jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Install + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake + + - name: Configure, build + run: | + mkdir build + cd build + cmake .. + cmake --build . + + - name: Run tests + run: | + cd build + ./ChaosTests/ChaosTests + build-and-benchmark: runs-on: ubuntu-latest diff --git a/.gitea/workflows/ChaosTestCI.yaml b/.gitea/workflows/ChaosTestCI.yaml deleted file mode 100644 index 443d0ab..0000000 --- a/.gitea/workflows/ChaosTestCI.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: ChaosTest CI - -on: [push, pull_request] - -jobs: - build-and-test: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - - - name: Install - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake - - - name: Configure, build - run: | - mkdir build - cd build - cmake .. - cmake --build . - - - name: Run tests - run: | - cd build - ./ChaosTests/ChaosTests \ No newline at end of file From d30d5f8a742b3011434dabb15a631b230ec770ce Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 25 Jan 2026 17:48:57 +0300 Subject: [PATCH 6/8] Build benchmarks with CMAKE_BUILD_TYPE=Release --- .gitea/workflows/ChaosCI.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/ChaosCI.yaml b/.gitea/workflows/ChaosCI.yaml index 84eadd3..85ec931 100644 --- a/.gitea/workflows/ChaosCI.yaml +++ b/.gitea/workflows/ChaosCI.yaml @@ -47,7 +47,7 @@ jobs: run: | mkdir build cd build - cmake .. + cmake .. -D CMAKE_BUILD_TYPE=Release cmake --build . - name: Run benchmarks From 28334d1d78b351c3734991f92e9b250043fa4253 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 25 Jan 2026 18:07:41 +0300 Subject: [PATCH 7/8] Run tests and benchmarks in one job --- .gitea/workflows/ChaosCI.yaml | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.gitea/workflows/ChaosCI.yaml b/.gitea/workflows/ChaosCI.yaml index 85ec931..d510b51 100644 --- a/.gitea/workflows/ChaosCI.yaml +++ b/.gitea/workflows/ChaosCI.yaml @@ -24,33 +24,19 @@ jobs: cmake .. cmake --build . + - name: Configure, build [Release] + run: | + mkdir build-release + cd build-release + cmake .. -D CMAKE_BUILD_TYPE=Release + cmake --build . + - name: Run tests run: | cd build ./ChaosTests/ChaosTests - build-and-benchmark: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - - - name: Install - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake - - - name: Configure, build - run: | - mkdir build - cd build - cmake .. -D CMAKE_BUILD_TYPE=Release - cmake --build . - - name: Run benchmarks run: | - cd build + cd build-release ./ChaosBenches/ChaosBenches \ No newline at end of file From b9eb1a5fc86e239aca4e39bf11424f15f11582d1 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 25 Jan 2026 18:11:26 +0300 Subject: [PATCH 8/8] Rename job build-and-test --> test-and-benchmark --- .gitea/workflows/ChaosCI.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/ChaosCI.yaml b/.gitea/workflows/ChaosCI.yaml index d510b51..89b83f9 100644 --- a/.gitea/workflows/ChaosCI.yaml +++ b/.gitea/workflows/ChaosCI.yaml @@ -3,7 +3,7 @@ name: Chaos CI on: [push, pull_request] jobs: - build-and-test: + test-and-benchmark: runs-on: ubuntu-latest steps: