{"id":17347292,"url":"https://github.com/realtimechris/benchmarksuite","last_synced_at":"2025-10-29T00:49:14.440Z","repository":{"id":241989846,"uuid":"808001976","full_name":"RealTimeChris/BenchmarkSuite","owner":"RealTimeChris","description":"A suite of benchmarks.","archived":false,"fork":false,"pushed_at":"2024-12-04T09:32:25.000Z","size":1878,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-04T09:37:17.096Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RealTimeChris.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-30T07:32:47.000Z","updated_at":"2024-12-04T08:50:32.000Z","dependencies_parsed_at":"2024-06-21T09:23:43.594Z","dependency_job_id":"f7c1487c-599e-4787-af2a-3d79f089450a","html_url":"https://github.com/RealTimeChris/BenchmarkSuite","commit_stats":null,"previous_names":["realtimechris/benchmarkingsuite","realtimechris/benchmarksuite"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealTimeChris%2FBenchmarkSuite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealTimeChris%2FBenchmarkSuite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealTimeChris%2FBenchmarkSuite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealTimeChris%2FBenchmarkSuite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RealTimeChris","download_url":"https://codeload.github.com/RealTimeChris/BenchmarkSuite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228407838,"owners_count":17915080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T16:48:17.070Z","updated_at":"2025-10-29T00:49:14.415Z","avatar_url":"https://github.com/RealTimeChris.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Benchmark Suite\n\nHello and welcome to bnch_swt or \"Benchmark Suite\". This is a collection of classes/functions for the purpose of benchmarking CPU performance.\n\nThe following operating systems and compilers are officially supported:\n\n### Compiler Support\n----\n![MSVC](https://img.shields.io/github/actions/workflow/status/RealTimeChris/BenchmarkSuite/MSVC-Windows.yml?style=plastic\u0026logo=microsoft\u0026logoColor=green\u0026label=MSVC\u0026labelColor=pewter\u0026color=blue\u0026branch=main)\n![GCC](https://img.shields.io/github/actions/workflow/status/RealTimeChris/BenchmarkSuite/GCC-Ubuntu.yml?style=plastic\u0026logo=linux\u0026logoColor=green\u0026label=GCC\u0026labelColor=pewter\u0026color=blue\u0026branch=main)\n![CLANG](https://img.shields.io/github/actions/workflow/status/RealTimeChris/BenchmarkSuite/CLANG-MacOS.yml?style=plastic\u0026logo=apple\u0026logoColor=green\u0026label=CLANG\u0026labelColor=pewter\u0026color=blue\u0026branch=main)\n\n### Operating System Support\n----\n![Windows](https://img.shields.io/github/actions/workflow/status/RealTimeChris/BenchmarkSuite/MSVC-Windows.yml?style=plastic\u0026logo=microsoft\u0026logoColor=green\u0026label=Windows\u0026labelColor=pewter\u0026color=blue\u0026branch=main)\n![Linux](https://img.shields.io/github/actions/workflow/status/RealTimeChris/BenchmarkSuite/GCC-Ubuntu.yml?style=plastic\u0026logo=linux\u0026logoColor=green\u0026label=Linux\u0026labelColor=pewter\u0026color=blue\u0026branch=main)\n![Mac](https://img.shields.io/github/actions/workflow/status/RealTimeChris/BenchmarkSuite/CLANG-MacOS.yml?style=plastic\u0026logo=apple\u0026logoColor=green\u0026label=MacOS\u0026labelColor=pewter\u0026color=blue\u0026branch=main)\n\n# Quickstart Guide for BenchmarkSuite\n\nThis guide will walk you through setting up and running benchmarks using `BenchmarkSuite`.\n\n## Table of Contents\n- [Installation](#installation)\n- [Basic Example](#basic-example)\n- [Creating Benchmarks](#creating-benchmarks)\n- [Running Benchmarks](#running-benchmarks)\n- [Output and Results](#output-and-results)\n\n## Installation\nTo use `BenchmarkSuite`, include the necessary header files in your project. Ensure you have a C++23 (or later) compliant compiler.\n\n```cpp\n#include \u003cBnchSwt/BenchmarkSuite.hpp\u003e\n#include \u003cvector\u003e\n#include \u003cstring\u003e\n#include \u003ccstring\u003e\n```\n\n## Basic Example\nThe following example demonstrates how to set up and run a benchmark comparing two integer-to-string conversion functions:\n\n```cpp\ntemplate\u003cuint64_t count, typename value_type, bnch_swt::string_literal testName\u003e\nBNCH_SWT_INLINE void testFunction() {\n    std::vector\u003cvalue_type\u003e testValues{ generateRandomIntegers\u003cvalue_type\u003e(count, sizeof(value_type) == 4 ? 10 : 20) };\n    std::vector\u003cstd::string\u003e testValues00;\n    std::vector\u003cstd::string\u003e testValues01(count);\n\n    for (uint64_t x = 0; x \u003c count; ++x) {\n        testValues00.emplace_back(std::to_string(testValues[x]));\n    }\n\n    bnch_swt::benchmark_stage\u003c\"old-vs-new-i-to-str\" + testName\u003e::template runBenchmark\u003c\"glz::to_chars\", \"CYAN\"\u003e([\u0026] {\n        uint64_t bytesProcessed = 0;\n        char newerString[30]{};\n        for (uint64_t x = 0; x \u003c count; ++x) {\n            std::memset(newerString, '\\0', sizeof(newerString));\n            auto newPtr = to_chars(newerString, testValues[x]);\n            bytesProcessed += testValues00[x].size();\n            testValues01[x] = std::string{newerString, static_cast\u003cuint64_t\u003e(newPtr - newerString)};\n        }\n        bnch_swt::doNotOptimizeAway(bytesProcessed);\n        return bytesProcessed;\n    });\n\n    bnch_swt::benchmark_stage\u003c\"old-vs-new-i-to-str\" + testName\u003e::template runBenchmark\u003c\"jsonifier_internal::toChars\", \"CYAN\"\u003e([\u0026] {\n        uint64_t bytesProcessed = 0;\n        char newerString[30]{};\n        for (uint64_t x = 0; x \u003c count; ++x) {\n            std::memset(newerString, '\\0', sizeof(newerString));\n            auto newPtr = jsonifier_internal::toChars(newerString, testValues[x]);\n            bytesProcessed += testValues00[x].size();\n            testValues01[x] = std::string{newerString, static_cast\u003cuint64_t\u003e(newPtr - newerString)};\n        }\n        bnch_swt::doNotOptimizeAway(bytesProcessed);\n        return bytesProcessed;\n    });\n\n    bnch_swt::benchmark_stage\u003c\"old-vs-new-i-to-str\" + testName\u003e::printResults(true, false);\n}\n\nint main() {\n    testFunction\u003c512, uint64_t, \"-uint64\"\u003e();\n    testFunction\u003c512, int64_t, \"-int64\"\u003e();\n    return 0;\n}\n```\n\n## Creating Benchmarks\nTo create a benchmark:\n1. Generate or initialize test data.\n2. Use `bnch_swt::benchmark_stage` to define a benchmark. By setting the name of the `bnch_swt::benchmark_stage` using a string literal, you are instantiating a single \"stage\" within which to execute different benchmarks.\n3. Implement test functions with lambdas capturing your benchmark logic.\n\n### Benchmark Stage\nThe `benchmark_stage` structure orchestrates each test:\n\n### Methods\n- `runBenchmark()`: Executes a given lambda function, measuring performance. By setting the name of the benchmark 'run' using a string literal, you are instantiating a single benchmark \"entity\" or \"library\" to have its data collected and compared, within the given benchmark stage.\n- `printResults()`: Displays detailed performance metrics and comparisons.\n\n### Example Benchmark Definitions\n- **`runBenchmark`**: Executes a lambda function and tracks performance.\n  - `\"glz::to_chars\"`: A label for the function being benchmarked.\n  - `\"jsonifier_internal::toChars\"`: An alternative implementation to compare.\n\n### Avoiding Compiler Optimizations\nUse `bnch_swt::doNotOptimizeAway` to prevent the compiler from optimizing away results.\n\n## Running Benchmarks\nCompile and run your program:\n\n## Output and Results\n```c\nPerformance Metrics for: int-to-string-comparisons-1\nMetrics for: jsonifier::internal::toChars\nTotal Iterations to Stabilize                               : 394\nMeasured Iterations                                         : 20\nBytes Processed                                             : 512.00\nNanoseconds per Execution                                   : 5785.25\nFrequency (GHz)                                             : 4.83\nThroughput (MB/s)                                           : 84.58\nThroughput Percentage Deviation (+/-%)                      : 8.36\nCycles per Execution                                        : 27921.20\nCycles per Byte                                             : 54.53\nInstructions per Execution                                  : 52026.00\nInstructions per Cycle                                      : 1.86\nInstructions per Byte                                       : 101.61\nBranches per Execution                                      : 361.45\nBranch Misses per Execution                                 : 0.73\nCache References per Execution                              : 97.03\nCache Misses per Execution                                  : 74.68\n----------------------------------------\nMetrics for: glz::to_chars\nTotal Iterations to Stabilize                               : 421\nMeasured Iterations                                         : 20\nBytes Processed                                             : 512.00\nNanoseconds per Execution                                   : 6480.30\nFrequency (GHz)                                             : 4.68\nThroughput (MB/s)                                           : 75.95\nThroughput Percentage Deviation (+/-%)                      : 17.58\nCycles per Execution                                        : 30314.40\nCycles per Byte                                             : 59.21\nInstructions per Execution                                  : 51513.00\nInstructions per Cycle                                      : 1.70\nInstructions per Byte                                       : 100.61\nBranches per Execution                                      : 438.25\nBranch Misses per Execution                                 : 0.73\nCache References per Execution                              : 95.93\nCache Misses per Execution                                  : 73.59\n----------------------------------------\nLibrary jsonifier::internal::toChars, is faster than library: glz::to_chars, by roughly: 11.36%.\n```\n\nThis structured output helps you quickly identify which implementation is faster or more efficient.\n\n---\n\nNow you’re ready to start benchmarking with **BenchmarkSuite**!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealtimechris%2Fbenchmarksuite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealtimechris%2Fbenchmarksuite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealtimechris%2Fbenchmarksuite/lists"}