11# Boost Benchmarks
22
3- This project contains benchmarks for the Boost C++ library using Google Benchmark. It tests various components of the Boost library with different input sizes and configurations to measure performance characteristics .
3+ A benchmarking suite for comparing performance of various Boost C++ library components using Google Benchmark.
44
55## Requirements
66
7- - CMake (3.14 or higher)
8- - C++ compiler with C++17 support
9- - Boost library with the following components:
10- - serialization
11- - graph
12- - Internet connection (for downloading Google Benchmark)
7+ - CMake 3.14+
8+ - C++17 compiler
9+ - Boost 1.87.0+ (with serialization and graph components)
1310
1411## Building
1512
@@ -19,7 +16,11 @@ mkdir -p build
1916cd build
2017
2118# Configure and build
22- cmake ..
19+ # For regular timing-based benchmarks:
20+ cmake -DCODSPEED_MODE=walltime ..
21+ # For CodSpeed instrumentation:
22+ cmake -DCODSPEED_MODE=instrumentation ..
23+
2324make
2425```
2526
@@ -28,101 +29,56 @@ make
2829From the build directory:
2930
3031``` bash
31- # Run all benchmarks
32- ./boost_bench
33-
34- # Run specific benchmarks (using regex filter)
35- ./boost_bench --benchmark_filter=" src/string_bench.h::BM_BoostStringSplit"
36-
37- # List all available benchmarks
38- ./boost_bench --benchmark_list_tests
32+ # Run individual component benchmarks
33+ ./string_bench
34+ ./container_bench
35+ ./utility_bench
36+ ./optional_bench
37+ ./spirit_bench
38+ ./multiindex_bench
39+ ./graph_bench
40+ ./serialization_bench
41+
42+ # Run all benchmarks with a single command
43+ cmake --build . --target run_all_benchmarks
44+
45+ # Pass arguments to all benchmarks
46+ cmake --build . --target run_all_benchmarks -- --benchmark_filter=BM_Boost
47+
48+ # Run with regex filter
49+ ./string_bench --benchmark_filter=" BM_BoostLexicalCast"
50+
51+ # List available benchmarks
52+ ./string_bench --benchmark_list_tests
3953```
4054
41- ### CodSpeed Integration
55+ ## Benchmark Categories
4256
43- This project is set up to run benchmarks in CI using [ CodSpeed] ( https://codspeed.io/ ) . When a pull request is opened or code is pushed to the main branch, GitHub Actions will automatically build and run the benchmarks, reporting the results to CodSpeed.
57+ - ** string_bench** : String operations, lexical_cast, regex, format
58+ - ** container_bench** : Container performance comparisons
59+ - ** utility_bench** : Type-safe any, algorithms, UUID generation
60+ - ** optional_bench** : Boost vs std::optional
61+ - ** spirit_bench** : Parsing operations (CSV, JSON, expressions)
62+ - ** multiindex_bench** : Multi-index container operations
63+ - ** graph_bench** : Graph algorithms (Dijkstra, A* , BFS, DFS)
64+ - ** serialization_bench** : Serialization performance (text, binary, XML)
4465
45- #### CI Workflow
66+ ## Custom Boost Version
4667
47- The GitHub Actions workflow:
48- 1 . Installs necessary tools and dependencies:
49- - CMake and GCC for building
50- - Required Boost components (serialization, graph)
51- 2 . Configures the project with CodSpeed instrumentation
52- 3 . Builds the project
53- 4 . Runs all benchmarks and reports results to CodSpeed
68+ Specify a custom Boost version:
5469
55- #### Local CodSpeed Testing
70+ ``` bash
71+ cmake -DBOOST_VERSION=1.82.0 -DCODSPEED_MODE=walltime ..
72+ ```
5673
57- To enable CodSpeed instrumentation locally:
74+ ## CodSpeed Integration
75+
76+ This project integrates with [ CodSpeed] ( https://codspeed.io/ ) for CI performance tracking. For local testing, use:
5877
5978``` bash
60- mkdir -p build && cd build
6179cmake -DCODSPEED_MODE=instrumentation ..
6280make
63-
64- # Run the benchmarks with CodSpeed instrumentation
65- ./boost_bench
81+ ./string_bench # Will show notice about running outside CI
6682```
6783
68- You'll see a message like this when running with CodSpeed instrumentation locally:
69- ```
70- NOTICE: codspeed is enabled, but no performance measurement will be made since it's running in an unknown environment.
71- ```
72-
73- This is normal as CodSpeed metrics are only collected in CI environments.
74-
75- You'll need to set up a ` CODSPEED_TOKEN ` secret in your GitHub repository settings for the CodSpeed integration to work in CI.
76-
77- ## Notes
78-
79- - CodSpeed's fork of Google Benchmark is automatically downloaded and configured via CMake's FetchContent
80- - The benchmarks are parameterized to test with different input sizes (small, medium, large)
81- - The project is organized into modular benchmark files for better maintainability
82- - CodSpeed integration allows performance tracking in CI
83-
84- ## Benchmark Categories
85-
86- ### String and Text Processing
87- - String splitting via boost::algorithm::split
88- - Integer and floating-point conversion via boost::lexical_cast
89- - Regular expressions via boost::regex
90- - String formatting via boost::format
91-
92- ### Containers
93- - Container performance comparisons:
94- - boost::container::flat_map vs std::map
95- - boost::container::vector vs std::vector
96-
97- ### Utility Libraries
98- - Type-safe any type via boost::any
99- - Algorithms: boost::algorithm::all_of
100- - UUID generation with boost::uuid
101- - Optional types: boost::optional vs std::optional
102-
103- ### Multi-Index Containers
104- - Insertion performance vs standard containers
105- - Lookup by different indices (ID, email)
106- - Range-based queries
107- - Modification with reindexing
108-
109- ### Spirit (Parsing)
110- - CSV data parsing
111- - JSON structure parsing
112- - Calculator expression parsing
113-
114- ### Graph Algorithms
115- - Dijkstra's shortest path algorithm
116- - A* search on grid graphs
117- - Breadth-First Search (BFS)
118- - Depth-First Search (DFS)
119-
120- ### Serialization
121- - Text archive performance
122- - Binary archive performance
123- - XML archive performance
124- - Format comparison (text vs binary vs XML)
125-
126- ## Adding new benchmarks
127-
128- Add new benchmark functions to the corresponding header file in the ` src/ ` directory, or create a new header file for a new category of benchmarks.
84+ For CI integration, ensure the ` CODSPEED_TOKEN ` secret is set in your GitHub repository.
0 commit comments