@@ -31,7 +31,7 @@ const (
3131 redisTLSCert = "tls_cert"
3232 redisTLSKey = "tls_key"
3333 redisTLSInsecureSkipVerify = "tls_insecure_skip_verify"
34- timestampSize = 13 // UnixMilli () produces 13 -digit number
34+ timestampSize = 19 // UnixNano () produces 19 -digit number
3535)
3636
3737const Inf = rate .Limit (math .MaxFloat64 )
@@ -75,7 +75,7 @@ func publisherRoutine(clientName string, channels []string, mode string, measure
7575
7676 // Pre-generate payload once per goroutine
7777 // For RTT mode: we'll use a template with padding that we'll prepend timestamp to
78- // Timestamp format: 13 bytes (e.g., "1762249648882 ")
78+ // Timestamp format: 19 bytes (e.g., "1762259663660769761 ")
7979 // Format: "<timestamp> <padding>" to reach dataSize
8080 var paddingPayload string
8181 if measureRTT && dataSize > timestampSize + 1 {
@@ -101,7 +101,7 @@ func publisherRoutine(clientName string, channels []string, mode string, measure
101101 time .Sleep (r .Delay ())
102102 }
103103 if measureRTT {
104- now := time .Now ().UnixMilli ()
104+ now := time .Now ().UnixNano ()
105105 if dataSize > timestampSize + 1 {
106106 // Format: "<timestamp> <padding>"
107107 msg = strconv .FormatInt (int64 (now ), 10 ) + " " + paddingPayload
@@ -215,9 +215,9 @@ func subscriberRoutine(clientName, mode string, channels []string, verbose bool,
215215 log .Println (fmt .Sprintf ("received message in channel %s. Message: %s" , msg .Channel , msg .Payload ))
216216 }
217217 if measureRTT {
218- now := time .Now ().UnixMicro ()
218+ now := time .Now ().UnixNano ()
219219 // Extract timestamp from payload (format: "<timestamp> <padding>" or just "<timestamp>")
220- // Timestamp is always 13 bytes (UnixMilli )
220+ // Timestamp is always 19 bytes (UnixNano )
221221 timestampStr := msg .Payload
222222 if len (msg .Payload ) > timestampSize {
223223 timestampStr = msg .Payload [:timestampSize ]
@@ -226,7 +226,7 @@ func subscriberRoutine(clientName, mode string, channels []string, verbose bool,
226226 rtt := now - ts
227227 rttLatencyChannel <- rtt
228228 if verbose {
229- log .Printf ("RTT measured: %d ms \n " , rtt / 1000 )
229+ log .Printf ("RTT measured: %d ns \n " , rtt )
230230 }
231231 } else {
232232 log .Printf ("Invalid timestamp in message: %s, err: %v\n " , timestampStr , err )
@@ -244,7 +244,7 @@ func main() {
244244 rps := flag .Int64 ("rps" , 0 , "Max rps for publisher mode. If 0 no limit is applied and the DB is stressed up to maximum." )
245245 rpsburst := flag .Int64 ("rps-burst" , 0 , "Max rps burst for publisher mode. If 0 the allowed burst will be the amount of clients." )
246246 password := flag .String ("a" , "" , "Password for Redis Auth." )
247- dataSize := flag .Int ("data-size" , 128 , "Payload size in bytes. In RTT mode, timestamp (13 bytes) + space + padding to reach this size." )
247+ dataSize := flag .Int ("data-size" , 128 , "Payload size in bytes. In RTT mode, timestamp (19 bytes) + space + padding to reach this size." )
248248 mode := flag .String ("mode" , "subscribe" , "Mode: 'subscribe', 'ssubscribe', 'publish', or 'spublish'." )
249249 username := flag .String ("user" , "" , "Used to send ACL style 'AUTH username pass'. Needs -a." )
250250 subscribers_placement := flag .String ("subscribers-placement-per-channel" , "dense" , "(dense,sparse) dense - Place all subscribers to channel in a specific shard. sparse- spread the subscribers across as many shards possible, in a round-robin manner." )
0 commit comments