Commit 97b965a7 authored by Weixin Deng's avatar Weixin Deng
Browse files

Add summary output

parent 24760b77
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
......@@ -23,6 +24,7 @@ type Args struct {
addr string
numPorts int
ports []string
numBackends int
numServers int
servers []string
dataSize int
......@@ -47,6 +49,7 @@ func parseArgs() Args {
startClient: *startClient,
addr: *addr,
numPorts: *numPorts,
numBackends: *numBackends,
numServers: numServers,
dataSize: *dataSize,
serverDelay: *serverDelay,
......@@ -198,7 +201,14 @@ func startClient(args *Args) {
delayTotal = end.Sub(start)
dataSizeTotal := args.dataSize * 8 * args.numServers
throughput := int64(dataSizeTotal) * 1e9 / delayTotal.Nanoseconds()
fmt.Println()
fmt.Println("Summary")
fmt.Println("DstAddr,Start,End,Duration,DurationUS")
for i := 0; i < args.numServers; i++ {
dstAddr := args.servers[i]
clock := clocks[i]
fmt.Printf("%s,%s,%s,%s,%d\n",
dstAddr, clock.Start, clock.End, clock.Duration, clock.Duration.Microseconds())
}
fmt.Printf("DelayAvg: %s\n", delayAvg)
fmt.Printf("DelayTotal: %s\n", delayTotal)
fmt.Printf("Throughput: %dbps\n", throughput)
......@@ -221,6 +231,15 @@ func startServer(args *Args) {
func main() {
args := parseArgs()
if args.startClient {
params := make(map[string]any)
params["Ports"] = args.numPorts
params["Backends"] = args.numBackends
params["Servers"] = args.numServers
params["DataSize"] = args.dataSize
params["ServerDelay"] = args.serverDelay
paramsJson, err := json.MarshalIndent(params, "", "\t")
Assert(err == nil, err)
fmt.Println(string(paramsJson))
for i := 0; i < args.repeat; i++ {
startClient(&args)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment