Add option --relative
This commit is contained in:
parent
3d9133f93f
commit
dbf10affb4
|
@ -18,6 +18,7 @@ var (
|
|||
|
||||
client = app.Command("client", "Request measurement")
|
||||
serverAddress = client.Arg("address", "Address:port to connect to").String()
|
||||
relativeTimes = client.Flag("relative", "Print times relative to start").Bool()
|
||||
)
|
||||
|
||||
func tcpdelayServer() {
|
||||
|
@ -56,6 +57,7 @@ func tcpdelayServer() {
|
|||
}
|
||||
|
||||
func tcpdelayClient() {
|
||||
t0 := time.Now().UnixNano()
|
||||
conn, err := net.Dial("tcp", *serverAddress)
|
||||
if err != nil {
|
||||
log.Fatal("Cannot connect to ", *serverAddress, err)
|
||||
|
@ -83,7 +85,11 @@ func tcpdelayClient() {
|
|||
log.Fatal("Unexpected offset ", oSent, " instead of ", o)
|
||||
}
|
||||
ts := binary.BigEndian.Uint64(buffer[16:])
|
||||
fmt.Println(o, ts, tr) // XXX - buffer for performance
|
||||
if *relativeTimes {
|
||||
fmt.Println(o, int64(ts)-t0, tr-t0)
|
||||
} else {
|
||||
fmt.Println(o, ts, tr)
|
||||
}
|
||||
o += n
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue