-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (48 loc) · 1.27 KB
/
main.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
package main
import (
"fmt"
"net/http"
"strings"
"time"
"code.cloudfoundry.org/cf-networking-helpers/json_client"
"code.cloudfoundry.org/lager"
)
func main() {
logger := lager.NewLogger("test")
jsonClient := json_client.New(logger, http.DefaultClient, "https://c2c-test.cfapps.io")
nSamples := 1000
sampleOne(jsonClient)
netmanSamples := []time.Duration{}
kawasakiSamples := []time.Duration{}
for i := 0; i < nSamples; i++ {
duration, isNetman, err := sampleOne(jsonClient)
if err != nil {
panic(err)
}
if isNetman {
netmanSamples = append(netmanSamples, duration)
} else {
kawasakiSamples = append(kawasakiSamples, duration)
}
}
report(netmanSamples, "NETMAN")
report(kawasakiSamples, "KAWASAKI")
}
func sampleOne(jsonClient json_client.JsonClient) (time.Duration, bool, error) {
startTime := time.Now()
var resp struct{ ListenAddresses []string }
err := jsonClient.Do("GET", "/", nil, &resp, "")
if err != nil {
return time.Duration(0), false, err
}
isNetman := strings.Contains(resp.ListenAddresses[1], "10.255")
return time.Since(startTime), isNetman, nil
}
func report(samples []time.Duration, name string) {
fmt.Println("")
fmt.Println(name)
fmt.Println()
for _, sample := range samples {
fmt.Printf("%f\n", sample.Seconds())
}
}