diff --git a/README.md b/README.md index adb36f3..07a2a00 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,89 @@ ## About -:construction: WIP +Benchttp engine is a Go library providing a way to perform benchmarks and tests +on HTTP endpoints. ## Installation -:construction: WIP +### Prerequisites + +Go1.17 environment or higher is required. + +Install. + +```txt +go get github.com/benchttp/engine +``` ## Usage -:construction: WIP +### Basic usage + +```go +package main + +import ( + "context" + "fmt" + + "github.com/benchttp/engine/runner" +) + +func main(t *testing.T) { + // Set runner configuration + config := runner.DefaultConfig() + config.Request = config.Request.WithURL("https://example.com") + + // Instantiate runner and run benchmark + report, _ := runner.New(nil).Run(context.Background(), config) + + fmt.Println(report.Metrics.ResponseTimes.Mean) +} +``` + +### Usage with JSON config via `configparse` + +```go +package main + +import ( + "context" + "fmt" + + "github.com/benchttp/engine/configparse" + "github.com/benchttp/engine/runner" +) + +func main() { + // JSON configuration obtained via e.g. a file or HTTP call + jsonConfig := []byte(` +{ + "request": { + "url": "https://example.com" + } +}`) + + config, _ := configparse.JSON(jsonConfig) + report, _ := runner.New(nil).Run(context.Background(), config) + + fmt.Println(report.Metrics.ResponseTimes.Mean) +} +``` + +📄 Please refer to [our Wiki](https://github.com/benchttp/engine/wiki/IO-Structures) for exhaustive `Config` and `Report` structures (and more!) + +## Development + +### Prerequisites + +1. Go 1.17 or higher is required +1. Golangci-lint for linting files + +### Main commands + +| Command | Description | +| ------------ | ----------------------------------- | +| `make lint` | Runs lint on the codebase | +| `make tests` | Runs tests suites from all packages | +| `make check` | Runs both lint and tests |