Adjust requests to be constant equal to b.N in network tests.
For "hey", requests >= concurrency. b.N can be set by the --test.benchtime={b.N}x. The previous setting of b.N * c can be surprisingly slow for larger c. Set the requests to max(b.N, c) and log to the user if it is c. PiperOrigin-RevId: 347053675
This commit is contained in:
parent
4cba3904f4
commit
305a456551
|
@ -82,9 +82,14 @@ func benchmarkHttpdDocSize(b *testing.B, reverse bool) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to parse parameters: %v", err)
|
b.Fatalf("Failed to parse parameters: %v", err)
|
||||||
}
|
}
|
||||||
|
requests := b.N
|
||||||
|
if requests < c {
|
||||||
|
b.Logf("b.N is %d must be greater than threads %d. Consider running with --test.benchtime=Nx where N >= %d", b.N, c, c)
|
||||||
|
requests = c
|
||||||
|
}
|
||||||
b.Run(name, func(b *testing.B) {
|
b.Run(name, func(b *testing.B) {
|
||||||
hey := &tools.Hey{
|
hey := &tools.Hey{
|
||||||
Requests: c * b.N,
|
Requests: requests,
|
||||||
Concurrency: c,
|
Concurrency: c,
|
||||||
Doc: filename,
|
Doc: filename,
|
||||||
}
|
}
|
||||||
|
@ -116,6 +121,7 @@ func benchmarkHttpdContinuous(b *testing.B, concurrency []int, sizes []string, r
|
||||||
|
|
||||||
requests := b.N
|
requests := b.N
|
||||||
if requests < c {
|
if requests < c {
|
||||||
|
b.Logf("b.N is %d must be greater than threads %d. Consider running with --test.benchtime=Nx where N >= %d", b.N, c, c)
|
||||||
requests = c
|
requests = c
|
||||||
}
|
}
|
||||||
b.Run(name, func(b *testing.B) {
|
b.Run(name, func(b *testing.B) {
|
||||||
|
|
|
@ -92,9 +92,14 @@ func benchmarkNginxDocSize(b *testing.B, reverse, tmpfs bool) {
|
||||||
b.Fatalf("Failed to parse parameters: %v", err)
|
b.Fatalf("Failed to parse parameters: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requests := b.N
|
||||||
|
if requests < c {
|
||||||
|
b.Logf("b.N is %d must be greater than threads %d. Consider running with --test.benchtime=Nx where N >= %d", b.N, c, c)
|
||||||
|
requests = c
|
||||||
|
}
|
||||||
b.Run(name, func(b *testing.B) {
|
b.Run(name, func(b *testing.B) {
|
||||||
hey := &tools.Hey{
|
hey := &tools.Hey{
|
||||||
Requests: c * b.N,
|
Requests: requests,
|
||||||
Concurrency: c,
|
Concurrency: c,
|
||||||
Doc: filename,
|
Doc: filename,
|
||||||
}
|
}
|
||||||
|
@ -128,9 +133,9 @@ func benchmarkNginxContinuous(b *testing.B, concurrency []int, sizes []string, r
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to parse parameters: %v", err)
|
b.Fatalf("Failed to parse parameters: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
requests := b.N
|
requests := b.N
|
||||||
if requests < c {
|
if requests < c {
|
||||||
|
b.Logf("b.N is %d must be greater than threads %d. Consider running with --test.benchtime=Nx where N >= %d", b.N, c, c)
|
||||||
requests = c
|
requests = c
|
||||||
}
|
}
|
||||||
b.Run(name, func(b *testing.B) {
|
b.Run(name, func(b *testing.B) {
|
||||||
|
|
|
@ -42,9 +42,14 @@ func BenchmarkNode(b *testing.B) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to parse parameters: %v", err)
|
b.Fatalf("Failed to parse parameters: %v", err)
|
||||||
}
|
}
|
||||||
|
requests := b.N
|
||||||
|
if requests < c {
|
||||||
|
b.Logf("b.N is %d must be greater than threads %d. Consider running with --test.benchtime=Nx where N >= %d", b.N, c, c)
|
||||||
|
requests = c
|
||||||
|
}
|
||||||
b.Run(name, func(b *testing.B) {
|
b.Run(name, func(b *testing.B) {
|
||||||
hey := &tools.Hey{
|
hey := &tools.Hey{
|
||||||
Requests: b.N * c, // Requests b.N requests per thread.
|
Requests: requests,
|
||||||
Concurrency: c,
|
Concurrency: c,
|
||||||
}
|
}
|
||||||
runNode(b, hey)
|
runNode(b, hey)
|
||||||
|
|
|
@ -43,9 +43,14 @@ func BenchmarkRuby(b *testing.B) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to parse parameters: %v", err)
|
b.Fatalf("Failed to parse parameters: %v", err)
|
||||||
}
|
}
|
||||||
|
requests := b.N
|
||||||
|
if requests < c {
|
||||||
|
b.Logf("b.N is %d must be greater than threads %d. Consider running with --test.benchtime=Nx where N >= %d", b.N, c, c)
|
||||||
|
requests = c
|
||||||
|
}
|
||||||
b.Run(name, func(b *testing.B) {
|
b.Run(name, func(b *testing.B) {
|
||||||
hey := &tools.Hey{
|
hey := &tools.Hey{
|
||||||
Requests: b.N * c, // b.N requests per thread.
|
Requests: requests,
|
||||||
Concurrency: c,
|
Concurrency: c,
|
||||||
}
|
}
|
||||||
runRuby(b, hey)
|
runRuby(b, hey)
|
||||||
|
|
Loading…
Reference in New Issue