|
|
@ -14,6 +14,7 @@ import ( |
|
|
|
var testConf = &Config{ |
|
|
|
var testConf = &Config{ |
|
|
|
Target: 20, |
|
|
|
Target: 20, |
|
|
|
Internal: 500, |
|
|
|
Internal: 500, |
|
|
|
|
|
|
|
MaxOutstanding: 20, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var qps = time.Microsecond * 2000 |
|
|
|
var qps = time.Microsecond * 2000 |
|
|
@ -22,9 +23,10 @@ func TestCoDel1200(t *testing.T) { |
|
|
|
q := New(testConf) |
|
|
|
q := New(testConf) |
|
|
|
drop := new(int64) |
|
|
|
drop := new(int64) |
|
|
|
tm := new(int64) |
|
|
|
tm := new(int64) |
|
|
|
|
|
|
|
accept := new(int64) |
|
|
|
delay := time.Millisecond * 3000 |
|
|
|
delay := time.Millisecond * 3000 |
|
|
|
testPush(q, qps, delay, drop, tm) |
|
|
|
testPush(q, qps, delay, drop, tm, accept) |
|
|
|
fmt.Printf("qps %v process time %v drop %d timeout %d \n", int64(time.Second/qps), delay, *drop, *tm) |
|
|
|
fmt.Printf("qps %v process time %v drop %d timeout %d accept %d \n", int64(time.Second/qps), delay, *drop, *tm, *accept) |
|
|
|
time.Sleep(time.Second) |
|
|
|
time.Sleep(time.Second) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -32,9 +34,10 @@ func TestCoDel200(t *testing.T) { |
|
|
|
q := New(testConf) |
|
|
|
q := New(testConf) |
|
|
|
drop := new(int64) |
|
|
|
drop := new(int64) |
|
|
|
tm := new(int64) |
|
|
|
tm := new(int64) |
|
|
|
|
|
|
|
accept := new(int64) |
|
|
|
delay := time.Millisecond * 2000 |
|
|
|
delay := time.Millisecond * 2000 |
|
|
|
testPush(q, qps, delay, drop, tm) |
|
|
|
testPush(q, qps, delay, drop, tm, accept) |
|
|
|
fmt.Printf("qps %v process time %v drop %d timeout %d \n", int64(time.Second/qps), delay, *drop, *tm) |
|
|
|
fmt.Printf("qps %v process time %v drop %d timeout %d accept %d \n", int64(time.Second/qps), delay, *drop, *tm, *accept) |
|
|
|
time.Sleep(time.Second) |
|
|
|
time.Sleep(time.Second) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -42,21 +45,23 @@ func TestCoDel100(t *testing.T) { |
|
|
|
q := New(testConf) |
|
|
|
q := New(testConf) |
|
|
|
drop := new(int64) |
|
|
|
drop := new(int64) |
|
|
|
tm := new(int64) |
|
|
|
tm := new(int64) |
|
|
|
|
|
|
|
accept := new(int64) |
|
|
|
delay := time.Millisecond * 1000 |
|
|
|
delay := time.Millisecond * 1000 |
|
|
|
testPush(q, qps, delay, drop, tm) |
|
|
|
testPush(q, qps, delay, drop, tm, accept) |
|
|
|
fmt.Printf("qps %v process time %v drop %d timeout %d \n", int64(time.Second/qps), delay, *drop, *tm) |
|
|
|
fmt.Printf("qps %v process time %v drop %d timeout %d accept %d \n", int64(time.Second/qps), delay, *drop, *tm, *accept) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestCoDel50(t *testing.T) { |
|
|
|
func TestCoDel50(t *testing.T) { |
|
|
|
q := New(testConf) |
|
|
|
q := New(testConf) |
|
|
|
drop := new(int64) |
|
|
|
drop := new(int64) |
|
|
|
tm := new(int64) |
|
|
|
tm := new(int64) |
|
|
|
delay := time.Millisecond * 500 |
|
|
|
accept := new(int64) |
|
|
|
testPush(q, qps, delay, drop, tm) |
|
|
|
delay := time.Millisecond * 50 |
|
|
|
fmt.Printf("qps %v process time %v drop %d timeout %d \n", int64(time.Second/qps), delay, *drop, *tm) |
|
|
|
testPush(q, qps, delay, drop, tm, accept) |
|
|
|
|
|
|
|
fmt.Printf("qps %v process time %v drop %d timeout %d accept %d \n", int64(time.Second/qps), delay, *drop, *tm, *accept) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func testPush(q *Queue, sleep time.Duration, delay time.Duration, drop *int64, tm *int64) { |
|
|
|
func testPush(q *Queue, sleep time.Duration, delay time.Duration, drop *int64, tm *int64, accept *int64) { |
|
|
|
var group sync.WaitGroup |
|
|
|
var group sync.WaitGroup |
|
|
|
for i := 0; i < 5000; i++ { |
|
|
|
for i := 0; i < 5000; i++ { |
|
|
|
time.Sleep(sleep) |
|
|
|
time.Sleep(sleep) |
|
|
@ -72,6 +77,7 @@ func testPush(q *Queue, sleep time.Duration, delay time.Duration, drop *int64, t |
|
|
|
atomic.AddInt64(tm, 1) |
|
|
|
atomic.AddInt64(tm, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
atomic.AddInt64(accept, 1) |
|
|
|
time.Sleep(delay) |
|
|
|
time.Sleep(delay) |
|
|
|
q.Pop() |
|
|
|
q.Pop() |
|
|
|
} |
|
|
|
} |
|
|
|