Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Duckdb Duckdb Build Benchmarks Flag

From Leeroopedia


Overview

Build_Benchmarks_Flag is the concrete tool for enabling benchmark compilation in DuckDB via the BUILD_BENCHMARKS CMake option. This flag controls whether the benchmark/ subdirectory is included in the CMake build graph, and consequently whether the benchmark_runner executable is produced. The flag is exposed both through direct CMake invocation and through convenience Makefile targets.

Code Reference

CMake Option Definition

Source: CMakeLists.txt:L429

option(BUILD_BENCHMARKS "Enable building of benchmarks" FALSE)

This declares the BUILD_BENCHMARKS option with a default value of FALSE. It is only activated when explicitly set to TRUE by the developer or CI pipeline.

Conditional Subdirectory Inclusion

Source: CMakeLists.txt:L843-846

if(BUILD_BENCHMARKS)
    add_subdirectory(benchmark)
endif()

When BUILD_BENCHMARKS is TRUE, CMake processes the benchmark/ subdirectory, which defines the benchmark_runner target and all associated benchmark registration code.

Makefile Convenience Target

Source: Makefile:L349-353

releasebenchmark:
	mkdir -p build/release && \
	cd build/release && \
	cmake $(GENERATOR) $(FORCE_COLOR) ${WARNINGS_AS_ERRORS} ${FORCE_WARN_UNUSED_FLAG} \
		${DISABLE_UNITY_FLAG} ${DISABLE_SANITIZER_FLAG} ${STATIC_OPENSSL} \
		-DBUILD_BENCHMARKS=TRUE -DCMAKE_BUILD_TYPE=Release ../.. && \
	cmake --build . --config Release

This target configures a release build with benchmarks enabled. It can be invoked via:

BUILD_BENCHMARKS=1 make release

Parameters

Parameter Type Default Description
BUILD_BENCHMARKS BOOL FALSE Controls whether the benchmark subdirectory is included in the build. Must be set to TRUE to compile benchmark targets.
BUILD_UNITTESTS BOOL TRUE Controls compilation of unit test infrastructure. Must also be TRUE when benchmarks are enabled, as the benchmark runner depends on shared test utilities.

I/O Contract

Inputs

  • DuckDB source tree -- The complete DuckDB repository, including the benchmark/ subdirectory with benchmark source files and .benchmark DSL files.
  • CMake configuration -- A valid CMake configuration with BUILD_BENCHMARKS=TRUE set, either via command-line flag or through the Makefile target.

Outputs

  • build/release/benchmark/benchmark_runner -- The compiled benchmark runner executable. This binary contains all registered benchmarks and can be invoked to list, filter, and execute benchmarks.

Usage Examples

Building via Make

# Build a release configuration with benchmarks enabled
BUILD_BENCHMARKS=1 make release

Building via CMake Directly

mkdir -p build/release
cd build/release
cmake -DBUILD_BENCHMARKS=TRUE -DCMAKE_BUILD_TYPE=Release ../..
cmake --build . --config Release

Verifying the Build

# Confirm the benchmark_runner was produced
ls -la build/release/benchmark/benchmark_runner

# List available benchmarks
build/release/benchmark/benchmark_runner --list

Related

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment