From 83a8c07981d19f1ef77c0a269fb09f8111990fad Mon Sep 17 00:00:00 2001 From: Gregory Albouy Date: Sun, 9 Oct 2022 21:43:27 +0200 Subject: [PATCH 1/4] docs: write Readme documentation --- README.md | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index adb36f3..85b4e76 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 +## Usage -:construction: WIP +### Prerequisites -## Usage +- Go1.17 environment or higher + +### Install dependency + +```txt +go get github.com/benchttp/engine +``` + +### Usage + +#### 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!) + +## Contributing: set up develpment environment + +### Prerequisites + +1. Go 1.17 or higher is required +1. Golangci-lint for linting files + +### Main commands -:construction: WIP +| Command | Description | +| ------------ | ----------------------------------- | +| `make lint` | Runs lint on the codebase | +| `make tests` | Runs tests suites from all packages | +| `make check` | Runs both lint and tests | From f9aace759b7c00c27bdc9c8076c6a1c08504a51b Mon Sep 17 00:00:00 2001 From: Gregory Albouy Date: Sun, 9 Oct 2022 21:59:32 +0200 Subject: [PATCH 2/4] docs: fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85b4e76..c3ec67b 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ func main() { 📄 Please refer to [our Wiki](https://github.com/benchttp/engine/wiki/IO-Structures) for exhaustive `Config` and `Report` structures (and more!) -## Contributing: set up develpment environment +## Contributing: set up development environment ### Prerequisites From 5ee4bd1123266703358bc5eecb754b17ac607113 Mon Sep 17 00:00:00 2001 From: Gregory Albouy Date: Sun, 9 Oct 2022 22:02:30 +0200 Subject: [PATCH 3/4] docs: title change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c3ec67b..34d684f 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ func main() { 📄 Please refer to [our Wiki](https://github.com/benchttp/engine/wiki/IO-Structures) for exhaustive `Config` and `Report` structures (and more!) -## Contributing: set up development environment +## Development ### Prerequisites From 264d89fb8ee3eb8205e480e4b8d359e1b5349e92 Mon Sep 17 00:00:00 2001 From: moreirathomas Date: Sun, 9 Oct 2022 23:30:28 +0200 Subject: [PATCH 4/4] misc: dedup usage title --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 34d684f..07a2a00 100644 --- a/README.md +++ b/README.md @@ -19,21 +19,21 @@ Benchttp engine is a Go library providing a way to perform benchmarks and tests on HTTP endpoints. -## Usage +## Installation ### Prerequisites -- Go1.17 environment or higher +Go1.17 environment or higher is required. -### Install dependency +Install. ```txt go get github.com/benchttp/engine ``` -### Usage +## Usage -#### Basic usage +### Basic usage ```go package main @@ -57,17 +57,17 @@ func main(t *testing.T) { } ``` -#### Usage with JSON config via `configparse` +### Usage with JSON config via `configparse` ```go package main import ( - "context" - "fmt" + "context" + "fmt" - "github.com/benchttp/engine/configparse" - "github.com/benchttp/engine/runner" + "github.com/benchttp/engine/configparse" + "github.com/benchttp/engine/runner" ) func main() {