-
Notifications
You must be signed in to change notification settings - Fork 0
/
workerqueue_test.go
61 lines (54 loc) · 1.15 KB
/
workerqueue_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package workerqueue
import (
// "math/rand"
"testing"
"time"
)
func TestDispatcher_Run_Test_10m(t *testing.T) {
delay := 10 * time.Millisecond
jobs := []Job{
newJob("1", delay),
newJob("2", delay),
newJob("3", delay),
newJob("4", delay),
newJob("5", delay),
newJob("6", delay),
newJob("7", delay),
newJob("8", delay),
newJob("9", delay),
newJob("10", delay),
}
d := NewDispatcher("dp_1", 5)
d.Run()
for _, j := range jobs {
d.AddJob(j)
}
time.Sleep(1 * time.Millisecond)
d.Stop()
}
// func BenchmarkDispatcher1(b *testing.B) {
// // run the Fib function b.N times
// for n := 0; n < b.N; n++ {
// delay := time.Duration(rand.Intn(1000)) * time.Millisecond
// b.Log(b.N, delay)
// jobs := []Job{
// newJob("1", delay),
// newJob("2", delay),
// newJob("3", delay),
// newJob("4", delay),
// newJob("5", delay),
// newJob("6", delay),
// newJob("7", delay),
// newJob("8", delay),
// newJob("9", delay),
// newJob("10", delay),
// }
// d := NewDispatcher("dp_1", 5)
// d.Run()
// for _, j := range jobs {
// d.AddJob(j)
// }
// time.Sleep(1 * time.Millisecond)
// d.Stop()
// }
// }