-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.go
More file actions
55 lines (46 loc) · 1.01 KB
/
Copy pathtest.go
File metadata and controls
55 lines (46 loc) · 1.01 KB
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
package main
import (
"bytes"
// "fmt"
"github.com/edwardtoday/skyeye/client"
// "github.com/edwardtoday/skyeye/utils"
"math/rand"
"time"
)
func randomString(l int) string {
var result bytes.Buffer
var temp string
for i := 0; i < l; {
if string(randInt(48, 57)) != temp {
temp = string(randInt(48, 57))
result.WriteString(temp)
i++
}
}
return result.String()
}
func randInt(min int, max int) int {
rand.Seed(time.Now().UTC().UnixNano())
return min + rand.Intn(max-min)
}
func main() {
cid := make(chan int)
numBenchmark := 1000
numRun := 1
testIds := make([]string, numBenchmark*numRun)
for i := 0; i < len(testIds); i++ {
testIds[i] = "test" + randomString(11)
}
client.NewDevices(testIds)
defer client.DelDevices(testIds)
for j := 0; j < numRun; j++ {
for i := 0; i < numBenchmark; i++ {
go client.CreateClient(cid, testIds[i+j*numBenchmark])
time.Sleep(1 * time.Millisecond)
}
time.Sleep(1000 * time.Millisecond)
}
for i := 0; i < numBenchmark*numRun; i++ {
<-cid
}
}