Skip to content

Commit ed465d9

Browse files
csv, discrete measurements
Signed-off-by: Colin Sullivan <colin@synadia.com>
1 parent b74c7a7 commit ed465d9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

natsthru/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ func sendMsgs(nc *nats.Conn, subject string, size, window int) {
188188
fmt.Printf("couldn't subscribe: %v", err)
189189
}
190190

191+
fmt.Printf("Window, Rate (msgs/sec), Rate (bytes/sec), Rate (readable)\n")
191192
var requestInProgress bool
192193
var i int
193194
var outstanding int
194-
start := time.Now()
195-
lastPrint := time.Now()
195+
ts := time.Now()
196196
for {
197197
nc.Publish(subject, payload)
198198
i++
@@ -221,11 +221,12 @@ func sendMsgs(nc *nats.Conn, subject string, size, window int) {
221221

222222
outstanding = 0
223223
requestInProgress = false
224-
if time.Since(lastPrint) > time.Second*3 {
225-
mps := float64(i) / time.Since(start).Seconds()
224+
if time.Since(ts) > time.Second*3 {
225+
mps := float64(i) / time.Since(ts).Seconds()
226226
bps := int64(mps) * int64(size)
227-
fmt.Printf("Window: %d, Rate: %d msgs/sec, %s bytes/sec\n", w, int(mps), ByteCountIEC(bps))
228-
lastPrint = time.Now()
227+
fmt.Printf("%d, %d, %d, %s\n", w, int(mps), bps, ByteCountIEC(bps))
228+
ts = time.Now()
229+
i = 0
229230
}
230231
}
231232
}

0 commit comments

Comments
 (0)