Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 80 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,89 @@

## About

:construction: WIP
Benchttp engine is a Go library providing a way to perform benchmarks and tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: it's not really a lib in the way that it only has one way to be used. I think package don't bring that weight of composability with it.

Suggested change
Benchttp engine is a Go library providing a way to perform benchmarks and tests
Benchttp engine is a Go library package a way to perform benchmarks and tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, package sound a little more suitable for me too.

Suggested change
Benchttp engine is a Go library providing a way to perform benchmarks and tests
Benchttp engine is a Go package providing a way to perform benchmarks and tests

Copy link
Member Author

@GregoryAlbouy GregoryAlbouy Oct 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it's still a library, as opposed to an executable application — I felt important to make that clear, as "package" is used for both worlds in Go.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense too ! I leave judge on that :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong argument about it either, so OK for library if you prefer it.

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 |