bencher

command module
v0.0.0-...-3201664 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 25 Imported by: 0

README

Bencher

Bencher is a command line utility that runs and versions go benchmarks in an isolated and scheduled environment.

You can schedule benchmarks on the fly without caring about versioning, implications of your local environment, unfair resource allocation or boring waiting times.

Installation

go install github.com/schattian/bencher

Motivation

Trying several different approaches when optimizing was a pain for me, since you need to wait until the latest benchmark finished to start a new one (otherwise, you end up sharing resources, which makes benchmarks more unreliable).

Also, I wanted a way to try those approaches without the overhead of managing versions with a VCS (sometimes, I just want to try multiple little changes in specific combinations), so I added the restore command for this.

Finally, I wanted to allocate a certain amount of resources to the benchmarks, so they don't bother while I'm doing other stuff (personally, I use a separated docker host, see Recommendations).

Requirements

It runs using the docker api, which implies that you must be a docker client, but you don't need to have the docker CLI installed nor host the docker server (i.e: if you've the socket, it's fine). Also, the benchmarks need to be part of a go module, although it doesn't matter where you want to run them (e.g: if you run them in a subdir).

Usage

You can schedule multiple different benchmarks without thinking on your local environment

gif of run

You can get the current list of jobs and inspect the results for completed jobs

gif of ls

You can benchstat across two or more versions

gif of cmp

Each build is versioned and saved independently so you can restore them even if you discarded those changes before, specially handy when trying several different approaches

gif of restore

Finally, you can remove unwanted versions (or even stop the one running). Notice that this removes the local copy of the version, so you cannot restore it afterwards

gif of rm

Recommendations

More reliable results are obtained if you run them in a physically separated docker host (e.g: a raspi, a homeserver, a cloud instance). To do so, you can follow these steps:

  1. Ensure that you have ssh access to the machine.
  2. Set DOCKER_HOST=ssh://username@host:port.

The reason behind that is resource allocation. If you run/stop something while running the benchmarks, these could be affected indirectly (and, considering that most use a browser and slack/spotify, this is not negligible).

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL