### Setup Go Modules and Build CLI Source: https://github.com/bobheadxi/gobenchdata/blob/main/CONTRIBUTING.md Enable Go Modules, download dependencies, and install the gobenchdata binary. This is the initial setup for developing the CLI. ```sh export GO111MODULE=on go mod download make # install binary ``` -------------------------------- ### Install and Run Gobenchdata Web Server Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md Installs the gobenchdata tool and starts a local web server for visualizing benchmarks. Ensure you have Go installed and configured. ```sh go install go.bobheadxi.dev/gobenchdata@latest gobenchdata web generate --web.config-only . gobenchdata web serve # opens visualization in browser ``` -------------------------------- ### Install Dependencies and Serve Web App Source: https://github.com/bobheadxi/gobenchdata/blob/main/CONTRIBUTING.md Install Node.js dependencies and start the development server for the web application. This is used for testing the web UI locally. ```sh npm install npm run serve ``` -------------------------------- ### Serve Gobenchdata Web Application Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md Starts the built-in web application for visualizing benchmark data. This command is used to view generated reports interactively. ```sh gobenchdata web serve ``` -------------------------------- ### Install Gobenchdata CLI Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md Installs the latest version of the gobenchdata CLI using go install. This command is typically run once to set up the tool. ```sh go install go.bobheadxi.dev/gobenchdata@latest ``` -------------------------------- ### Gobenchdata Web Configuration Example Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md An example YAML configuration file for the gobenchdata web application. It defines the title, description, repository, benchmark file, and chart groups for visualization. ```yml title: gobenchdata web description: Benchmarks generated using 'gobenchdata' repository: https://github.com/bobheadxi/gobenchdata benchmarksFile: benchmarks.json chartGroups: - name: Demo Benchmarks description: | This is a demo for gobenchdata, a tool and GitHub action for setting up simple continuous benchmarks to monitor performance improvements and regressions in your Golang benchmarks! charts: - name: specify charts by package package: go.bobheadxi.dev/gobenchdata/demo - name: match on specific benchmarks across packages with glob patterns benchmarks: [ 'BenchmarkFib.' ] - name: More Demo Benchmarks description: Create multiple groups of benchmarks charts: - name: match by a combination of package and benchmarks package: go.bobheadxi.dev/gobenchdata/. benchmarks: [ 'BenchmarkPizzas.', '.FibSlow.' ] ``` -------------------------------- ### Custom Setup with GoBenchData Action Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md This YAML workflow shows how to use gobenchdata with a custom Go version. It checks out code, sets up the Go environment, and then runs the 'gobenchdata action' command, passing inputs as environment variables prefixed with 'INPUT_'. ```yaml name: gobenchdata publish on: push jobs: publish: runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: { go-version: "1.18" } - name: gobenchdata publish run: go run go.bobheadxi.dev/gobenchdata@v1 action env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} # Instead of 'with: ...', provide environment variables and # prefix each input variable with 'INPUT' INPUT_PRUNE_COUNT: 30 INPUT_GO_TEST_FLAGS: -cpu 1,2 INPUT_PUBLISH: true INPUT_PUBLISH_BRANCH: gh-pages ``` -------------------------------- ### Example Checks Configuration Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md A sample YAML configuration for gobenchdata checks. It defines a check named 'My Check' that monitors the percentage difference in NsPerOp for the 'diff' function, with a maximum allowed regression threshold of 10%. ```yaml checks: - name: My Check description: |- Define a check here - in this example, we caculate % difference for NsPerOp in the diff function. diff is a function where you receive two parameters, current and base, and in general this function should return a negative value for an improvement and a positive value for a regression. package: . benchmarks: [] diff: (current.NsPerOp - base.NsPerOp) / base.NsPerOp * 100 thresholds: max: 10 ``` -------------------------------- ### Generate Checks Configuration Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md Installs the gobenchdata tool and generates a default checks configuration file. Use this to define performance checks for your project. ```sh go install go.bobheadxi.dev/gobenchdata@latest gobenchdata checks generate ``` -------------------------------- ### GoBenchData Publish Workflow Example Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md This YAML workflow demonstrates how to use the gobenchdata GitHub Action to run benchmarks on push events, prune old data, set Go test flags, and publish results to the gh-pages branch. It requires a GITHUB_TOKEN secret. ```yaml name: gobenchdata publish on: push jobs: publish: runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@v2 - name: gobenchdata publish uses: bobheadxi/gobenchdata@v1 with: PRUNE_COUNT: 30 GO_TEST_FLAGS: -cpu 1,2 PUBLISH: true PUBLISH_BRANCH: gh-pages env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} ``` -------------------------------- ### Display Gobenchdata Help Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md Shows the help message for the gobenchdata CLI, listing available commands and options. Useful for exploring functionality. ```sh gobenchdata help ``` -------------------------------- ### Generate Demo Benchmark Data Source: https://github.com/bobheadxi/gobenchdata/blob/main/CONTRIBUTING.md Create a large history of benchmark data for testing and demonstration purposes. This command can be run multiple times to increase data size. ```sh make demo ``` -------------------------------- ### Run Code Generation Source: https://github.com/bobheadxi/gobenchdata/blob/main/CONTRIBUTING.md Execute all Go generate tasks and other code generation scripts. This ensures all necessary generated code is up-to-date. ```sh make generate ``` -------------------------------- ### Generate Gobenchdata Performance Checks Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md Initiates the generation of performance checks. This command prepares the system for evaluating benchmark results against defined criteria. ```sh gobenchdata checks generate ``` -------------------------------- ### Generate Gobenchdata Web Application Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md Generates the static files for the gobenchdata web application in the specified directory. This is useful for deploying to platforms like GitHub Pages. ```sh gobenchdata web generate ./app ``` -------------------------------- ### Generate JSON Report from Go Test Output Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md Pipes the output of 'go test -bench' to gobenchdata to generate a JSON benchmark report. This is the primary method for capturing benchmark results. ```sh go test -bench . -benchmem ./... | gobenchdata --json bench.json ``` -------------------------------- ### Evaluate Gobenchdata Performance Checks Source: https://github.com/bobheadxi/gobenchdata/blob/main/README.md Evaluates performance checks by comparing base and current benchmarks. This command is crucial for identifying performance regressions. ```sh gobenchdata checks eval ${base benchmarks} ${current benchmarks} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.