9
"github.com/containers/common/libnetwork/types"
12
func benchmarkParsePortMapping(b *testing.B, ports []types.PortMapping) {
13
for n := 0; n < b.N; n++ {
14
_, _ = ParsePortMapping(ports, nil)
18
func BenchmarkParsePortMappingNoPorts(b *testing.B) {
19
benchmarkParsePortMapping(b, nil)
22
func BenchmarkParsePortMapping1(b *testing.B) {
23
benchmarkParsePortMapping(b, []types.PortMapping{
32
func BenchmarkParsePortMapping100(b *testing.B) {
33
ports := make([]types.PortMapping, 0, 100)
34
for i := uint16(8080); i < 8180; i++ {
35
ports = append(ports, types.PortMapping{
42
benchmarkParsePortMapping(b, ports)
45
func BenchmarkParsePortMapping1k(b *testing.B) {
46
ports := make([]types.PortMapping, 0, 1000)
47
for i := uint16(8080); i < 9080; i++ {
48
ports = append(ports, types.PortMapping{
55
benchmarkParsePortMapping(b, ports)
58
func BenchmarkParsePortMapping10k(b *testing.B) {
59
ports := make([]types.PortMapping, 0, 30000)
60
for i := uint16(8080); i < 18080; i++ {
61
ports = append(ports, types.PortMapping{
68
benchmarkParsePortMapping(b, ports)
71
func BenchmarkParsePortMapping1m(b *testing.B) {
72
ports := make([]types.PortMapping, 0, 1000000)
73
for j := 0; j < 20; j++ {
74
for i := uint16(1); i <= 50000; i++ {
75
ports = append(ports, types.PortMapping{
79
HostIP: fmt.Sprintf("192.168.1.%d", j),
84
benchmarkParsePortMapping(b, ports)
87
func BenchmarkParsePortMappingReverse100(b *testing.B) {
88
ports := make([]types.PortMapping, 0, 100)
89
for i := uint16(8180); i > 8080; i-- {
90
ports = append(ports, types.PortMapping{
97
benchmarkParsePortMapping(b, ports)
100
func BenchmarkParsePortMappingReverse1k(b *testing.B) {
101
ports := make([]types.PortMapping, 0, 1000)
102
for i := uint16(9080); i > 8080; i-- {
103
ports = append(ports, types.PortMapping{
110
benchmarkParsePortMapping(b, ports)
113
func BenchmarkParsePortMappingReverse10k(b *testing.B) {
114
ports := make([]types.PortMapping, 0, 30000)
115
for i := uint16(18080); i > 8080; i-- {
116
ports = append(ports, types.PortMapping{
123
benchmarkParsePortMapping(b, ports)
126
func BenchmarkParsePortMappingReverse1m(b *testing.B) {
127
ports := make([]types.PortMapping, 0, 1000000)
128
for j := 0; j < 20; j++ {
129
for i := uint16(50000); i > 0; i-- {
130
ports = append(ports, types.PortMapping{
134
HostIP: fmt.Sprintf("192.168.1.%d", j),
139
benchmarkParsePortMapping(b, ports)
142
func BenchmarkParsePortMappingRange1(b *testing.B) {
143
benchmarkParsePortMapping(b, []types.PortMapping{
153
func BenchmarkParsePortMappingRange100(b *testing.B) {
154
benchmarkParsePortMapping(b, []types.PortMapping{
164
func BenchmarkParsePortMappingRange1k(b *testing.B) {
165
benchmarkParsePortMapping(b, []types.PortMapping{
175
func BenchmarkParsePortMappingRange10k(b *testing.B) {
176
benchmarkParsePortMapping(b, []types.PortMapping{
186
func BenchmarkParsePortMappingRange1m(b *testing.B) {
187
ports := make([]types.PortMapping, 0, 1000000)
188
for j := 0; j < 20; j++ {
189
ports = append(ports, types.PortMapping{
194
HostIP: fmt.Sprintf("192.168.1.%d", j),
198
benchmarkParsePortMapping(b, ports)