From 3b2d78e0f1c8981df82e5b38e0bf5f53eff4d246 Mon Sep 17 00:00:00 2001 From: "codspeed-hq[bot]" <117304815+codspeed-hq[bot]@users.noreply.github.com> Date: Tue, 19 May 2026 09:02:09 +0000 Subject: [PATCH 1/2] Add CodSpeed continuous performance testing --- .github/workflows/codspeed.yml | 51 ++++++++++++++++++++++++++++++++++ README.md | 1 + benchmark/CMakeLists.txt | 26 +++++++++++------ 3 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/codspeed.yml diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml new file mode 100644 index 000000000..60968fd96 --- /dev/null +++ b/.github/workflows/codspeed.yml @@ -0,0 +1,51 @@ +name: CodSpeed + +on: + push: + branches: [master] + pull_request: + # Allow CodSpeed to trigger backtest performance analysis + workflow_dispatch: + +permissions: + contents: read + id-token: write + +concurrency: + group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash -e -l {0} + +jobs: + benchmarks: + name: Run benchmarks + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set conda environment + uses: mamba-org/setup-micromamba@main + with: + environment-name: myenv + environment-file: environment-dev.yml + init-shell: bash + cache-downloads: true + + - name: Build benchmarks + run: | + cmake -G Ninja -Bbuild \ + -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ + -DBUILD_BENCHMARK=ON \ + -DXTENSOR_USE_XSIMD=ON \ + -DCODSPEED_MODE=simulation + cmake --build build --target benchmark_xtensor --parallel 8 + + - name: Run benchmarks + uses: CodSpeedHQ/action@v4 + with: + mode: simulation + run: ./build/benchmark/benchmark_xtensor diff --git a/README.md b/README.md index 0813d3438..19c5f9fe1 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ [![Doxygen -> gh-pages](https://github.com/xtensor-stack/xtensor/workflows/gh-pages/badge.svg)](https://xtensor-stack.github.io/xtensor) [![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/xtensor-stack/xtensor/stable?filepath=notebooks%2Fxtensor.ipynb) [![Zulip](https://img.shields.io/badge/social_chat-zulip-blue.svg)](https://xtensor.zulipchat.com/#narrow/channel/539553-Ask-anything) +[![CodSpeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/xtensor-stack/xtensor?utm_source=badge) Multi-dimensional arrays with broadcasting and lazy computing. diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 9928eb155..0d0ce5766 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -16,17 +16,26 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(XTENSOR_INCLUDE_DIR ${xtensor_INCLUDE_DIRS}) endif () -message(STATUS "Forcing tests build type to Release") -set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) +if(CODSPEED_MODE AND NOT CODSPEED_MODE STREQUAL "off") + message(STATUS "CodSpeed mode enabled (${CODSPEED_MODE}) - using RelWithDebInfo build type") + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) +else() + message(STATUS "Forcing tests build type to Release") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) +endif() include(CheckCXXCompilerFlag) string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") - CHECK_CXX_COMPILER_FLAG(-march=native arch_native_supported) - if(arch_native_supported AND NOT CMAKE_CXX_FLAGS MATCHES "-march") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") + # Skip -march=native for CodSpeed simulation mode (valgrind does not + # support all native instruction sets) + if(NOT (CODSPEED_MODE STREQUAL "simulation")) + CHECK_CXX_COMPILER_FLAG(-march=native arch_native_supported) + if(arch_native_supported AND NOT CMAKE_CXX_FLAGS MATCHES "-march") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") + endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -g -Wunused-parameter -Wextra -Wreorder") @@ -80,13 +89,14 @@ if(DOWNLOAD_GBENCHMARK OR GBENCHMARK_SRC_DIR) GIT_TAG main) FetchContent_Declare(googlebenchmark - GIT_REPOSITORY https://github.com/google/benchmark.git - GIT_TAG main) # need main for benchmark::benchmark + GIT_REPOSITORY https://github.com/CodSpeedHQ/codspeed-cpp.git + GIT_TAG main + SOURCE_SUBDIR google_benchmark) FetchContent_MakeAvailable( googletest googlebenchmark) - set(GBENCHMARK_INCLUDE_DIRS "${googlebenchmark_SOURCE_DIR}/include") + set(GBENCHMARK_INCLUDE_DIRS "${googlebenchmark_SOURCE_DIR}/google_benchmark/include") set(GBENCHMARK_LIBRARIES benchmark) else() find_package(benchmark REQUIRED) From 5ddec5d91a35a5584242ca3f36c6f6936e18fe2a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 May 2026 11:38:01 +0000 Subject: [PATCH 2/2] style: apply pre-commit formatting to CodSpeed workflow Agent-Logs-Url: https://github.com/xtensor-stack/xtensor/sessions/56d2451c-ecd1-4214-8576-e1961071a7af Co-authored-by: Alex-PLACET <2400067+Alex-PLACET@users.noreply.github.com> --- .github/workflows/codspeed.yml | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index 60968fd96..9e2c5999c 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -24,28 +24,28 @@ jobs: name: Run benchmarks runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: Set conda environment - uses: mamba-org/setup-micromamba@main - with: - environment-name: myenv - environment-file: environment-dev.yml - init-shell: bash - cache-downloads: true - - - name: Build benchmarks - run: | - cmake -G Ninja -Bbuild \ - -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ - -DBUILD_BENCHMARK=ON \ - -DXTENSOR_USE_XSIMD=ON \ - -DCODSPEED_MODE=simulation - cmake --build build --target benchmark_xtensor --parallel 8 - - - name: Run benchmarks - uses: CodSpeedHQ/action@v4 - with: - mode: simulation - run: ./build/benchmark/benchmark_xtensor + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set conda environment + uses: mamba-org/setup-micromamba@main + with: + environment-name: myenv + environment-file: environment-dev.yml + init-shell: bash + cache-downloads: true + + - name: Build benchmarks + run: | + cmake -G Ninja -Bbuild \ + -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ + -DBUILD_BENCHMARK=ON \ + -DXTENSOR_USE_XSIMD=ON \ + -DCODSPEED_MODE=simulation + cmake --build build --target benchmark_xtensor --parallel 8 + + - name: Run benchmarks + uses: CodSpeedHQ/action@v4 + with: + mode: simulation + run: ./build/benchmark/benchmark_xtensor