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
1 changed files with 13 additions and 11 deletions

View File

@ -1141,19 +1141,21 @@ func benchMarkRequest(subnet string, b *testing.B) {
}
}
func BenchmarkRequest_24(b *testing.B) {
a, _ := getAllocator(true)
benchmarkRequest(b, a, "10.0.0.0/24")
func BenchmarkRequest(b *testing.B) {
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)
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) {