Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0c7243b
refactor(configparse): implement Representation.Unmarshal
GregoryAlbouy Oct 15, 2022
1d18415
feat: remove Config methods that became irrelevant
GregoryAlbouy Oct 15, 2022
8757bfb
chore: remove unused IsConfigField
GregoryAlbouy Oct 18, 2022
763ffd8
refactor(configparse): rename Representation.Unmarshal
GregoryAlbouy Oct 18, 2022
6ecb641
deps: remove unused dependencies
GregoryAlbouy Oct 18, 2022
a99624a
refactor(runner): use *http.Request for Config.Request
GregoryAlbouy Oct 18, 2022
afe07de
refactor(runner): flatten packages runner, config, report
GregoryAlbouy Oct 18, 2022
5b2168b
refactor(configparse): minor param renaming
GregoryAlbouy Oct 19, 2022
3999dbd
refactor(runner): nuke Config, flatten Runner fields
GregoryAlbouy Oct 19, 2022
5cd1c80
refactor(runner): use httptest in unit tests
GregoryAlbouy Oct 22, 2022
da47ab3
chore: remove obsolete env file
GregoryAlbouy Oct 22, 2022
721986a
chore: clean up .gitignore
GregoryAlbouy Oct 22, 2022
96e99e7
chore: remove deprecated linters
GregoryAlbouy Oct 22, 2022
930c0ea
refactor(runner): remove unnecessary constructor
GregoryAlbouy Oct 23, 2022
e360b5e
docs: update docs
GregoryAlbouy Oct 23, 2022
e5cfd1e
refactor(configparse): JSON: use pointer destination param
GregoryAlbouy Oct 23, 2022
749fb6a
refactor: rename module and packages
GregoryAlbouy Oct 23, 2022
a970ab9
refactor: remove Makefile, use shell scripts
GregoryAlbouy Oct 23, 2022
c4fca54
chore(benchttp): remove Runner.Progress method
GregoryAlbouy Oct 23, 2022
6b7b9fe
refactor(benchttp): DefaultRunner
GregoryAlbouy Oct 23, 2022
b427482
feat(benchttp): implement request setters for Runner
GregoryAlbouy Oct 23, 2022
918ac76
docs: update README
GregoryAlbouy Oct 23, 2022
673862f
faet(runner): use value rexeivers
GregoryAlbouy Oct 28, 2022
c0449ad
test(runner) write unit tests for setters
GregoryAlbouy Oct 28, 2022
3492ed9
chore: remove remaining Config mentions
GregoryAlbouy Feb 19, 2023
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
1 change: 0 additions & 1 deletion .env.development

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
go-version: 1.17

- name: Install coverage tool
run: go get github.com/ory/go-acc
run: go install github.com/ory/go-acc@v0.2.8

# Check #1: Lint
- name: Lint
Expand All @@ -28,7 +28,7 @@ jobs:

# Check #2: Test & generate coverage report
- name: Test & coverage
run: make test-cov
run: ./script/coverage

- name: Upload coverage report
uses: codecov/codecov-action@v1.0.2
Expand Down
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# Env files
.env

# Binary files
/bin

# IDE files
/.vscode
/.idea
Expand All @@ -12,6 +6,3 @@
/.benchttp.yml
/.benchttp.yaml
/.benchttp.json

# Benchttp reports
/benchttp.report.*.json
5 changes: 1 addition & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ linters-settings:
extra-rules: true

goimports:
local-prefixes: github.com/benchttp/engine
local-prefixes: github.com/benchttp/sdk

misspell:
locale: US
Expand All @@ -131,7 +131,6 @@ linters:
disable-all: true
enable:
- bodyclose # enforce resp.Body.Close()
- deadcode
- dupl # duplicate code
- errcheck
- exportloopref
Expand All @@ -145,10 +144,8 @@ linters:
- prealloc # enforce capacity allocation when possible
- revive # golint enhancement
- staticcheck # go vet enhancement
- structcheck # unused struct fields
- testpackage # checks on tests (*_test)
- thelper # enforce t.Helper()
- varcheck # unused global var and const
- wastedassign
fast: false

Expand Down
45 changes: 0 additions & 45 deletions Makefile

This file was deleted.

52 changes: 28 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<img alt="Github Worklow Status" src="https://img.shields.io/github/actions/workflow/status/benchttp/engine/ci.yml?branch=main"></a>
<a href="https://codecov.io/gh/benchttp/engine">
<img alt="Code coverage" src="https://img.shields.io/codecov/c/gh/benchttp/engine?label=coverage"></a>
<a href="https://goreportcard.com/report/github.com/benchttp/engine">
<img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/benchttp/engine" /></a>
<a href="https://goreportcard.com/report/github.com/benchttp/sdk">
<img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/benchttp/sdk" /></a>
<br />
<a href="https://pkg.go.dev/github.com/benchttp/engine#section-documentation">
<a href="https://pkg.go.dev/github.com/benchttp/sdk#section-documentation">
<img alt="Go package Reference" src="https://img.shields.io/badge/pkg-reference-informational?logo=go" /></a>
<a href="https://github.com/benchttp/engine/releases">
<a href="https://github.com/benchttp/sdk/releases">
<img alt="Latest version" src="https://img.shields.io/github/v/tag/benchttp/engine?label=release"></a>
</p>

Expand All @@ -28,7 +28,7 @@ Go1.17 environment or higher is required.
Install.

```txt
go get github.com/benchttp/engine
go get github.com/benchttp/sdk
```

## Usage
Expand All @@ -42,16 +42,14 @@ import (
"context"
"fmt"

"github.com/benchttp/engine/runner"
"github.com/benchttp/sdk/benchttp"
)

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)
func main() {
report, _ := benchttp.
DefaultRunner(). // Default runner with safe configuration
WithNewRequest("GET", "http://localhost:3000", nil). // Attach request
Run(context.Background()) // Run benchmark, retrieve report

fmt.Println(report.Metrics.ResponseTimes.Mean)
}
Expand All @@ -66,27 +64,33 @@ import (
"context"
"fmt"

"github.com/benchttp/engine/configparse"
"github.com/benchttp/engine/runner"
"github.com/benchttp/sdk/benchttp"
"github.com/benchttp/sdk/configparse"
)

func main() {
// JSON configuration obtained via e.g. a file or HTTP call
jsonConfig := []byte(`
{
"request": {
"url": "https://example.com"
"url": "http://localhost:3000"
}
}`)

config, _ := configparse.JSON(jsonConfig)
report, _ := runner.New(nil).Run(context.Background(), config)
// Instantiate a base Runner (here the default with a safe configuration)
runner := benchttp.DefaultRunner()

// Parse the json configuration into the Runner
_ = configparse.JSON(jsonConfig, &runner)

// Run benchmark, retrieve report
report, _ := runner.Run(context.Background())

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!)
📄 Please refer to [our Wiki](https://github.com/benchttp/sdk/wiki/IO-Structures) for exhaustive `Runner` and `Report` structures (and more!)

## Development

Expand All @@ -97,8 +101,8 @@ func main() {

### 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 |
| Command | Description |
| --------------- | ------------------------------------------------- |
| `./script/lint` | Runs lint on the codebase |
| `./script/test` | Runs tests suites from all packages |
| `./script/doc` | Serves Go doc for this module at `localhost:9995` |
10 changes: 5 additions & 5 deletions runner/internal/config/error.go → benchttp/error.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package config
package benchttp

import "strings"

// InvalidConfigError is the errors returned by Global.Validate
// InvalidRunnerError is the errors returned by Runner.Validate
// when values are missing or invalid.
type InvalidConfigError struct {
type InvalidRunnerError struct {
Errors []error
}

// Error returns the joined errors of InvalidConfigError as a string.
func (e *InvalidConfigError) Error() string {
// Error returns the joined errors of InvalidRunnerError as a string.
func (e *InvalidRunnerError) Error() string {
const sep = "\n - "

var b strings.Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package config_test
package benchttp_test

import (
"errors"
"testing"

"github.com/benchttp/engine/runner/internal/config"
"github.com/benchttp/sdk/benchttp"
)

func TestInvalidConfigError_Error(t *testing.T) {
e := config.InvalidConfigError{
func TestInvalidRunnerError(t *testing.T) {
e := benchttp.InvalidRunnerError{
Errors: []error{
errors.New("error 0"),
errors.New("error 1\nwith new line"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package metrics
import (
"time"

"github.com/benchttp/engine/runner/internal/metrics/timestats"
"github.com/benchttp/engine/runner/internal/recorder"
"github.com/benchttp/sdk/benchttp/internal/metrics/timestats"
"github.com/benchttp/sdk/benchttp/internal/recorder"
)

type TimeStats = timestats.TimeStats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"testing"
"time"

"github.com/benchttp/engine/runner/internal/metrics"
"github.com/benchttp/engine/runner/internal/metrics/timestats"
"github.com/benchttp/engine/runner/internal/recorder"
"github.com/benchttp/sdk/benchttp/internal/metrics"
"github.com/benchttp/sdk/benchttp/internal/metrics/timestats"
"github.com/benchttp/sdk/benchttp/internal/recorder"
)

func TestNewAggregate(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package metrics
import (
"errors"

"github.com/benchttp/engine/internal/errorutil"
"github.com/benchttp/sdk/internal/errorutil"
)

// ErrUnknownField occurs when a Field is used with an invalid path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package metrics_test
import (
"testing"

"github.com/benchttp/engine/runner/internal/metrics"
"github.com/benchttp/sdk/benchttp/internal/metrics"
)

func TestField_Type(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package metrics
import (
"strings"

"github.com/benchttp/engine/runner/internal/reflectpath"
"github.com/benchttp/sdk/benchttp/internal/reflectpath"
)

// Value is a concrete metric value, e.g. 120 or 3 * time.Second.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"
"time"

"github.com/benchttp/engine/runner/internal/metrics"
"github.com/benchttp/engine/runner/internal/metrics/timestats"
"github.com/benchttp/sdk/benchttp/internal/metrics"
"github.com/benchttp/sdk/benchttp/internal/metrics/timestats"
)

func TestMetric_Compare(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
"time"

"github.com/benchttp/engine/runner/internal/metrics/timestats"
"github.com/benchttp/sdk/benchttp/internal/metrics/timestats"
)

func TestCompute(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"github.com/benchttp/engine/internal/dispatcher"
"github.com/benchttp/sdk/internal/dispatcher"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/benchttp/engine/internal/dispatcher"
"github.com/benchttp/sdk/internal/dispatcher"
)

var errTest = errors.New("test-generated error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package tests
import (
"errors"

"github.com/benchttp/engine/internal/errorutil"
"github.com/benchttp/engine/runner/internal/metrics"
"github.com/benchttp/sdk/benchttp/internal/metrics"
"github.com/benchttp/sdk/internal/errorutil"
)

var ErrUnknownPredicate = errors.New("tests: unknown predicate")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"
"time"

"github.com/benchttp/engine/runner/internal/metrics"
"github.com/benchttp/engine/runner/internal/tests"
"github.com/benchttp/sdk/benchttp/internal/metrics"
"github.com/benchttp/sdk/benchttp/internal/tests"
)

func TestPredicate(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tests
import (
"fmt"

"github.com/benchttp/engine/runner/internal/metrics"
"github.com/benchttp/sdk/benchttp/internal/metrics"
)

type Case struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"testing"
"time"

"github.com/benchttp/engine/runner/internal/metrics"
"github.com/benchttp/engine/runner/internal/metrics/timestats"
"github.com/benchttp/engine/runner/internal/tests"
"github.com/benchttp/sdk/benchttp/internal/metrics"
"github.com/benchttp/sdk/benchttp/internal/metrics/timestats"
"github.com/benchttp/sdk/benchttp/internal/tests"
)

func TestRun(t *testing.T) {
Expand Down
Loading