prints req/sec

This commit is contained in:
Radu Ioan Fericean
2012-07-07 12:07:24 +03:00
parent 43f88836b1
commit 41e8a496ed
4 changed files with 15 additions and 5 deletions

View File

@@ -43,6 +43,7 @@ func main() {
if err != nil {
log.Fatalf("could not connect to balancer: %v", err)
}
start := time.Now()
if *parallel {
var divCall *rpc.Call
for i := 0; i < *runs; i++ {
@@ -54,6 +55,8 @@ func main() {
client.Call("Responder.GetCost", cd, &result)
}
}
duration := time.Since(start)
log.Println(result)
client.Close()
log.Printf("Elapsed: %v resulted: %v req/s.", duration, float64(*runs)/duration.Seconds())
}

View File

@@ -36,12 +36,15 @@ func main() {
t2 := time.Date(2012, time.February, 02, 18, 30, 0, 0, time.UTC)
cd := timespans.CallDescriptor{Direction: "OUT", TOR: "0", Tenant: "vdf", Subject: "rif", Destination: "0256", TimeStart: t1, TimeEnd: t2}
result := timespans.CallCost{}
client, _ := jsonrpc.Dial("tcp", "localhost:5090")
client, _ := jsonrpc.Dial("tcp", "localhost:1234")
i := 0
start := time.Now()
for j := 0; j < *runs; j++ {
client.Call("Storage.GetCost", cd, &result)
client.Call("Responder.GetCost", cd, &result)
}
duration := time.Since(start)
log.Println(result)
log.Println(i)
log.Printf("Elapsed: %v resulted: %v req/s.", duration, float64(*runs)/duration.Seconds())
client.Close()
}

View File

@@ -58,15 +58,16 @@ func main() {
log.Printf("Runnning %d cycles...", *runs)
var result *timespans.CallCost
j := 0
start := time.Now()
for i := 0; i < *runs; i++ {
result, err = cd.GetCost()
j = i
}
duration := time.Since(start)
log.Print(result, j, err)
memstats := new(runtime.MemStats)
runtime.ReadMemStats(memstats)
log.Printf("memstats before GC: Kbytes = %d footprint = %d",
memstats.HeapAlloc/1024, memstats.Sys/1024)
log.Printf("Elapsed: %v resulted: %v req/s.", duration, float64(*runs)/duration.Seconds())
}

View File

@@ -33,7 +33,10 @@ type RedisStorage struct {
}
func NewRedisStorage(address string, db int) (*RedisStorage, error) {
ndb := godis.New("tcp:"+address, db, "")
if address != "" {
address = "tcp:" + address
}
ndb := godis.New(address, db, "")
ms := &MyMarshaler{}
return &RedisStorage{db: ndb, dbNb: db, ms: ms}, nil
}