1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

test: update tests to use sub-benchmarks

Go 1.7 added the subtest feature which can make table-driven tests much easier to run and debug. Some tests are not using this feature.

Signed-off-by: Yang Li <idealhack@gmail.com>
This commit is contained in:
Yang Li 2018-05-29 18:01:31 +08:00
parent 350fc8fc17
commit b0b5e14b77

View file

@ -1141,19 +1141,21 @@ func benchMarkRequest(subnet string, b *testing.B) {
} }
} }
func BenchmarkRequest_24(b *testing.B) { func BenchmarkRequest(b *testing.B) {
a, _ := getAllocator(true)
benchmarkRequest(b, a, "10.0.0.0/24") subnets := []string{
"10.0.0.0/24",
"10.0.0.0/16",
"10.0.0.0/8",
} }
func BenchmarkRequest_16(b *testing.B) { for _, subnet := range subnets {
name := fmt.Sprintf("%vSubnet", subnet)
b.Run(name, func(b *testing.B) {
a, _ := getAllocator(true) a, _ := getAllocator(true)
benchmarkRequest(b, a, "10.0.0.0/16") benchmarkRequest(b, a, subnet)
})
} }
func BenchmarkRequest_8(b *testing.B) {
a, _ := getAllocator(true)
benchmarkRequest(b, a, "10.0.0.0/8")
} }
func TestAllocateRandomDeallocate(t *testing.T) { func TestAllocateRandomDeallocate(t *testing.T) {