Commit 24760b77 authored by Weixin Deng's avatar Weixin Deng
Browse files

Adjust client args

parent 9c1c71ca
......@@ -2,7 +2,7 @@ go run ../src/service.go \
-client \
-addr "10.0.0.1" \
-numPorts 8 \
-numServers 8 \
-numBackends 1 \
-dataSize 1 \
-serverDelay 0 \
-repeat 10
......@@ -7,7 +7,6 @@ import (
"net"
"net/rpc"
"strconv"
"strings"
"sync"
"time"
)
......@@ -36,53 +35,38 @@ func parseArgs() Args {
var startClient = flag.Bool("client", false, "Start client")
var addr = flag.String("addr", "", "Address")
var numPorts = flag.Int("numPorts", 0, "Number of ports")
var ports = flag.String("ports", "", "Ports")
var numServers = flag.Int("numServers", 0, "Number of servers")
var servers = flag.String("servers", "", "Servers")
var numBackends = flag.Int("numBackends", 0, "Number of backends")
var dataSize = flag.Int("dataSize", 1, "Data size")
var serverDelay = flag.Int("serverDelay", 0, "Server delay in microseconds")
var repeat = flag.Int("repeat", 1, "Repeat")
flag.Parse()
Assert(len(*addr) > 0)
numServers := *numPorts * *numBackends
args := Args{
startServer: *startServer,
startClient: *startClient,
addr: *addr,
numPorts: *numPorts,
numServers: *numServers,
numServers: numServers,
dataSize: *dataSize,
serverDelay: *serverDelay,
repeat: *repeat,
}
if len(*ports) > 0 {
args.ports = strings.Fields(*ports)
} else {
var ports []string
for i := 0; i < *numPorts; i++ {
port := strconv.Itoa(9000 + i + 1)
ports = append(ports, port)
}
args.ports = ports
var ports []string
for i := 0; i < *numPorts; i++ {
port := strconv.Itoa(9000 + i + 1)
ports = append(ports, port)
}
Assert(len(args.ports) == args.numPorts,
"numPorts is not equal to the number of ports")
if len(*servers) > 0 {
args.servers = strings.Fields(*servers)
} else {
numBackends := *numServers / *numPorts
var servers []string
for i := 0; i < numBackends; i++ {
backendAddr := "10.0.0." + strconv.Itoa(i+2)
for j := 0; j < *numPorts; j++ {
serverAddr := backendAddr + ":" + args.ports[j]
servers = append(servers, serverAddr)
}
args.ports = ports
var servers []string
for i := 0; i < *numBackends; i++ {
backendAddr := "10.0.0." + strconv.Itoa(i+2)
for j := 0; j < *numPorts; j++ {
serverAddr := backendAddr + ":" + args.ports[j]
servers = append(servers, serverAddr)
}
args.servers = servers
fmt.Printf("numBackends: %d, numPorts: %d\n", numBackends, *numPorts)
}
Assert(len(args.servers) == args.numServers,
"numServers is not equal to the number of servers")
Assert(len(args.addr) > 0)
args.servers = servers
return args
}
......@@ -214,10 +198,10 @@ func startClient(args *Args) {
delayTotal = end.Sub(start)
dataSizeTotal := args.dataSize * 8 * args.numServers
throughput := int64(dataSizeTotal) * 1e9 / delayTotal.Nanoseconds()
fmt.Println()
fmt.Printf("DelayAvg: %s\n", delayAvg)
fmt.Printf("DelayTotal: %s\n", delayTotal)
fmt.Printf("Throughput: %dbps\n", throughput)
fmt.Println()
time.Sleep(1 * time.Second)
}
......
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