MCPcopy
hub / github.com/Terry-Mao/goim / main

Function main

benchmarks/push/main.go:51–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49}
50
51func main() {
52 runtime.GOMAXPROCS(runtime.NumCPU())
53 begin, err := strconv.Atoi(os.Args[1])
54 if err != nil {
55 panic(err)
56 }
57 length, err := strconv.Atoi(os.Args[2])
58 if err != nil {
59 panic(err)
60 }
61
62 t, err = strconv.Atoi(os.Args[4])
63 if err != nil {
64 panic(err)
65 }
66
67 num := runtime.NumCPU() * 2
68 log.Printf("start routine num:%d", num)
69
70 l := length / num
71 b, e := begin, begin+l
72 time.AfterFunc(time.Duration(t)*time.Second, stop)
73 for i := 0; i < num; i++ {
74 go startPush(b, e)
75 b += l
76 e += l
77 }
78 if b < begin+length {
79 go startPush(b, begin+length)
80 }
81
82 time.Sleep(9999 * time.Hour)
83}
84
85func stop() {
86 os.Exit(-1)

Callers

nothing calls this directly

Calls 2

PrintfMethod · 0.80
startPushFunction · 0.70

Tested by

no test coverage detected