mirror of
https://github.com/aykhans/dodo.git
synced 2025-08-31 00:33:34 +00:00
Compare commits
10 Commits
7fb59a7989
...
25d4762a3c
Author | SHA1 | Date | |
---|---|---|---|
25d4762a3c | |||
361d423651 | |||
ffa724fae7 | |||
7930be490d | |||
e6c54e9cb2 | |||
b32f567de7 | |||
b6e85d9443 | |||
827e3535cd | |||
7ecf534d87 | |||
![]() |
17ad5fadb9 |
2
.github/workflows/golangci-lint.yml
vendored
2
.github/workflows/golangci-lint.yml
vendored
@@ -21,5 +21,5 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v7
|
||||
with:
|
||||
version: v2.0.2
|
||||
version: v2.4.0
|
||||
args: --timeout=10m --config=.golangci.yml
|
||||
|
@@ -1,7 +1,7 @@
|
||||
version: "2"
|
||||
|
||||
run:
|
||||
go: "1.24"
|
||||
go: "1.25"
|
||||
concurrency: 8
|
||||
timeout: 10m
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.24-alpine AS builder
|
||||
FROM golang:1.25-alpine AS builder
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
<h1 align="center">Dodo - A Fast and Easy-to-Use HTTP Benchmarking Tool</h1>
|
||||
|
||||

|
||||
|
||||
<div align="center">
|
||||
<h4>
|
||||
<a href="./EXAMPLES.md">
|
||||
|
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
VERSION string = "0.7.2"
|
||||
VERSION string = "0.7.3"
|
||||
DefaultUserAgent string = "Dodo/" + VERSION
|
||||
DefaultMethod string = "GET"
|
||||
DefaultTimeout time.Duration = time.Second * 10
|
||||
|
12
go.mod
12
go.mod
@@ -1,11 +1,11 @@
|
||||
module github.com/aykhans/dodo
|
||||
|
||||
go 1.24.2
|
||||
go 1.25
|
||||
|
||||
require (
|
||||
github.com/brianvoe/gofakeit/v7 v7.3.0
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.8
|
||||
github.com/valyala/fasthttp v1.64.0
|
||||
github.com/valyala/fasthttp v1.65.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
@@ -15,8 +15,8 @@ require (
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
golang.org/x/net v0.42.0 // indirect
|
||||
golang.org/x/sys v0.34.0 // indirect
|
||||
golang.org/x/term v0.33.0 // indirect
|
||||
golang.org/x/text v0.27.0 // indirect
|
||||
golang.org/x/net v0.43.0 // indirect
|
||||
golang.org/x/sys v0.35.0 // indirect
|
||||
golang.org/x/term v0.34.0 // indirect
|
||||
golang.org/x/text v0.28.0 // indirect
|
||||
)
|
||||
|
20
go.sum
20
go.sum
@@ -19,18 +19,18 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.64.0 h1:QBygLLQmiAyiXuRhthf0tuRkqAFcrC42dckN2S+N3og=
|
||||
github.com/valyala/fasthttp v1.64.0/go.mod h1:dGmFxwkWXSK0NbOSJuF7AMVzU+lkHz0wQVvVITv2UQA=
|
||||
github.com/valyala/fasthttp v1.65.0 h1:j/u3uzFEGFfRxw79iYzJN+TteTJwbYkru9uDp3d0Yf8=
|
||||
github.com/valyala/fasthttp v1.65.0/go.mod h1:P/93/YkKPMsKSnATEeELUCkG8a7Y+k99uxNHVbKINr4=
|
||||
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
|
||||
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
|
||||
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
|
||||
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
|
||||
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg=
|
||||
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
|
||||
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
|
||||
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
|
||||
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
|
||||
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
|
||||
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
|
||||
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
|
||||
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
||||
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
@@ -14,47 +14,30 @@ type Response struct {
|
||||
Time time.Duration
|
||||
}
|
||||
|
||||
type Responses []*Response
|
||||
type Responses []Response
|
||||
|
||||
// Print prints the responses in a tabular format, including information such as
|
||||
// response count, minimum time, maximum time, average time, and latency percentiles.
|
||||
func (responses Responses) Print() {
|
||||
total := struct {
|
||||
Count int
|
||||
Min time.Duration
|
||||
Max time.Duration
|
||||
Sum time.Duration
|
||||
P90 time.Duration
|
||||
P95 time.Duration
|
||||
P99 time.Duration
|
||||
}{
|
||||
Count: len(responses),
|
||||
Min: responses[0].Time,
|
||||
Max: responses[0].Time,
|
||||
if len(responses) == 0 {
|
||||
return
|
||||
}
|
||||
mergedResponses := make(map[string]types.Durations)
|
||||
var allDurations types.Durations
|
||||
|
||||
for _, response := range responses {
|
||||
if response.Time < total.Min {
|
||||
total.Min = response.Time
|
||||
}
|
||||
if response.Time > total.Max {
|
||||
total.Max = response.Time
|
||||
}
|
||||
total.Sum += response.Time
|
||||
mergedResponses := make(map[string]types.Durations)
|
||||
|
||||
totalDurations := make(types.Durations, len(responses))
|
||||
var totalSum time.Duration
|
||||
totalCount := len(responses)
|
||||
|
||||
for i, response := range responses {
|
||||
totalSum += response.Time
|
||||
totalDurations[i] = response.Time
|
||||
|
||||
mergedResponses[response.Response] = append(
|
||||
mergedResponses[response.Response],
|
||||
response.Time,
|
||||
)
|
||||
allDurations = append(allDurations, response.Time)
|
||||
}
|
||||
allDurations.Sort()
|
||||
allDurationsLenAsFloat := float64(len(allDurations) - 1)
|
||||
total.P90 = allDurations[int(0.90*allDurationsLenAsFloat)]
|
||||
total.P95 = allDurations[int(0.95*allDurationsLenAsFloat)]
|
||||
total.P99 = allDurations[int(0.99*allDurationsLenAsFloat)]
|
||||
|
||||
t := table.NewWriter()
|
||||
t.SetOutputMirror(os.Stdout)
|
||||
@@ -93,15 +76,18 @@ func (responses Responses) Print() {
|
||||
}
|
||||
|
||||
if len(mergedResponses) > 1 {
|
||||
totalDurations.Sort()
|
||||
allDurationsLenAsFloat := float64(len(totalDurations) - 1)
|
||||
|
||||
t.AppendRow(table.Row{
|
||||
"Total",
|
||||
total.Count,
|
||||
utils.DurationRoundBy(total.Min, roundPrecision),
|
||||
utils.DurationRoundBy(total.Max, roundPrecision),
|
||||
utils.DurationRoundBy(total.Sum/time.Duration(total.Count), roundPrecision), // Average
|
||||
utils.DurationRoundBy(total.P90, roundPrecision),
|
||||
utils.DurationRoundBy(total.P95, roundPrecision),
|
||||
utils.DurationRoundBy(total.P99, roundPrecision),
|
||||
totalCount,
|
||||
utils.DurationRoundBy(totalDurations[0], roundPrecision),
|
||||
utils.DurationRoundBy(totalDurations[len(totalDurations)-1], roundPrecision),
|
||||
utils.DurationRoundBy(totalSum/time.Duration(totalCount), roundPrecision), // Average
|
||||
utils.DurationRoundBy(totalDurations[int(0.90*allDurationsLenAsFloat)], roundPrecision),
|
||||
utils.DurationRoundBy(totalDurations[int(0.95*allDurationsLenAsFloat)], roundPrecision),
|
||||
utils.DurationRoundBy(totalDurations[int(0.99*allDurationsLenAsFloat)], roundPrecision),
|
||||
})
|
||||
}
|
||||
t.Render()
|
||||
|
@@ -66,7 +66,7 @@ func releaseDodos(
|
||||
streamWG sync.WaitGroup
|
||||
requestCountPerDodo uint
|
||||
dodosCount = requestConfig.GetValidDodosCountForRequests()
|
||||
responses = make([][]*Response, dodosCount)
|
||||
responses = make([][]Response, dodosCount)
|
||||
increase = make(chan int64, requestConfig.RequestCount)
|
||||
)
|
||||
|
||||
@@ -123,7 +123,7 @@ func sendRequestByCount(
|
||||
request *Request,
|
||||
timeout time.Duration,
|
||||
requestCount uint,
|
||||
responseData *[]*Response,
|
||||
responseData *[]Response,
|
||||
increase chan<- int64,
|
||||
wg *sync.WaitGroup,
|
||||
) {
|
||||
@@ -146,7 +146,7 @@ func sendRequestByCount(
|
||||
if err == types.ErrInterrupt {
|
||||
return
|
||||
}
|
||||
*responseData = append(*responseData, &Response{
|
||||
*responseData = append(*responseData, Response{
|
||||
Response: err.Error(),
|
||||
Time: completedTime,
|
||||
})
|
||||
@@ -154,7 +154,7 @@ func sendRequestByCount(
|
||||
return
|
||||
}
|
||||
|
||||
*responseData = append(*responseData, &Response{
|
||||
*responseData = append(*responseData, Response{
|
||||
Response: strconv.Itoa(response.StatusCode()),
|
||||
Time: completedTime,
|
||||
})
|
||||
@@ -170,7 +170,7 @@ func sendRequest(
|
||||
ctx context.Context,
|
||||
request *Request,
|
||||
timeout time.Duration,
|
||||
responseData *[]*Response,
|
||||
responseData *[]Response,
|
||||
increase chan<- int64,
|
||||
wg *sync.WaitGroup,
|
||||
) {
|
||||
@@ -193,7 +193,7 @@ func sendRequest(
|
||||
if err == types.ErrInterrupt {
|
||||
return
|
||||
}
|
||||
*responseData = append(*responseData, &Response{
|
||||
*responseData = append(*responseData, Response{
|
||||
Response: err.Error(),
|
||||
Time: completedTime,
|
||||
})
|
||||
@@ -201,7 +201,7 @@ func sendRequest(
|
||||
return
|
||||
}
|
||||
|
||||
*responseData = append(*responseData, &Response{
|
||||
*responseData = append(*responseData, Response{
|
||||
Response: strconv.Itoa(response.StatusCode()),
|
||||
Time: completedTime,
|
||||
})
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
@@ -14,9 +15,7 @@ func (d Durations) Sort(ascending ...bool) {
|
||||
return d[i] > d[j]
|
||||
})
|
||||
} else { // Otherwise, sort in ascending order
|
||||
sort.Slice(d, func(i, j int) bool {
|
||||
return d[i] < d[j]
|
||||
})
|
||||
slices.Sort(d)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,8 +2,8 @@ package utils
|
||||
|
||||
import "math/rand"
|
||||
|
||||
func Flatten[T any](nested [][]*T) []*T {
|
||||
flattened := make([]*T, 0)
|
||||
func Flatten[T any](nested [][]T) []T {
|
||||
flattened := make([]T, 0)
|
||||
for _, n := range nested {
|
||||
flattened = append(flattened, n...)
|
||||
}
|
||||
|
Reference in New Issue
Block a user