@@ -18,7 +18,16 @@ import (
1818)
1919
2020var totalCommands uint64
21+ var totalEmptyResultsets uint64
2122var totalErrors uint64
23+
24+ var totalNodesCreated uint64
25+ var totalNodesDeleted uint64
26+ var totalLabelsAdded uint64
27+ var totalPropertiesSet uint64
28+ var totalRelationshipsCreated uint64
29+ var totalRelationshipsDeleted uint64
30+
2231var latencies * hdrhistogram.Histogram
2332var graphRunTimeLatencies * hdrhistogram.Histogram
2433
@@ -41,6 +50,8 @@ func sendCmdLogic(rg redisgraph.Graph, query string, continueOnError bool, debug
4150 startT := time .Now ()
4251 queryResult , err = rg .Query (query )
4352 endT := time .Now ()
53+ atomic .AddUint64 (& totalCommands , uint64 (1 ))
54+ duration := endT .Sub (startT )
4455 if err != nil {
4556 if continueOnError {
4657 atomic .AddUint64 (& totalErrors , uint64 (1 ))
@@ -50,17 +61,31 @@ func sendCmdLogic(rg redisgraph.Graph, query string, continueOnError bool, debug
5061 } else {
5162 log .Fatalf ("Received an error with the following query(s): %v, error: %v" , query , err )
5263 }
64+ } else {
65+ err = graphRunTimeLatencies .RecordValue (int64 (queryResult .RunTime () * 1000 ))
66+ if err != nil {
67+ log .Fatalf ("Received an error while recording RedisGraph RunTime latencies: %v" , err )
68+ }
69+ if debug_level > 1 {
70+ fmt .Printf ("Issued query: %s\n " , query )
71+ fmt .Printf ("Pretty printing result:\n " )
72+ queryResult .PrettyPrint ()
73+ fmt .Printf ("\n " )
74+ }
75+ if queryResult .Empty () {
76+ atomic .AddUint64 (& totalEmptyResultsets , uint64 (1 ))
77+ }
78+ atomic .AddUint64 (& totalNodesCreated , uint64 (queryResult .NodesCreated ()))
79+ atomic .AddUint64 (& totalNodesDeleted , uint64 (queryResult .NodesDeleted ()))
80+ atomic .AddUint64 (& totalLabelsAdded , uint64 (queryResult .LabelsAdded ()))
81+ atomic .AddUint64 (& totalPropertiesSet , uint64 (queryResult .PropertiesSet ()))
82+ atomic .AddUint64 (& totalRelationshipsCreated , uint64 (queryResult .RelationshipsCreated ()))
83+ atomic .AddUint64 (& totalRelationshipsDeleted , uint64 (queryResult .RelationshipsDeleted ()))
5384 }
54- duration := endT .Sub (startT )
5585 err = latencies .RecordValue (duration .Microseconds ())
5686 if err != nil {
5787 log .Fatalf ("Received an error while recording latencies: %v" , err )
5888 }
59- err = graphRunTimeLatencies .RecordValue (int64 (queryResult .RunTime () * 1000 ))
60- if err != nil {
61- log .Fatalf ("Received an error while recording RedisGraph RunTime latencies: %v" , err )
62- }
63- atomic .AddUint64 (& totalCommands , uint64 (1 ))
6489}
6590
6691func main () {
@@ -78,6 +103,7 @@ func main() {
78103 if len (args ) < 1 {
79104 log .Fatalf ("You need to specify a query after the flag command arguments." )
80105 }
106+ fmt .Printf ("Debug level: %d.\n " , * debug )
81107
82108 var requestRate = Inf
83109 var requestBurst = 1
@@ -112,7 +138,7 @@ func main() {
112138 wg .Add (1 )
113139 cmd := make ([]string , len (args ))
114140 copy (cmd , args )
115- go ingestionRoutine (getStandaloneConn (* graphKey , "tcp" , connectionStr ), true , query , samplesPerClient , * loop , int ( * debug ) , & wg , useRateLimiter , rateLimiter )
141+ go ingestionRoutine (getStandaloneConn (* graphKey , "tcp" , connectionStr ), true , query , samplesPerClient , * loop , * debug , & wg , useRateLimiter , rateLimiter )
116142 }
117143
118144 // listen for C-c
@@ -131,13 +157,22 @@ func main() {
131157 graph_p99IngestionMs := float64 (graphRunTimeLatencies .ValueAtQuantile (99.0 )) / 1000.0
132158
133159 fmt .Printf ("\n " )
134- fmt .Printf ("################################ #################\n " )
160+ fmt .Printf ("################# RUNTIME STATS #################\n " )
135161 fmt .Printf ("Total Duration %.3f Seconds\n " , duration .Seconds ())
136- fmt .Printf ("Total Errors %d\n " , totalErrors )
162+ fmt .Printf ("Total Commands issued %d\n " , totalCommands )
163+ fmt .Printf ("Total Errors %d ( %3.3f %%)\n " , totalErrors , float64 (totalErrors / totalCommands * 100.0 ))
137164 fmt .Printf ("Throughput summary: %.0f requests per second\n " , messageRate )
138165 fmt .Printf ("Overall Client Latency summary (msec):\n " )
139166 fmt .Printf (" %9s %9s %9s\n " , "p50" , "p95" , "p99" )
140167 fmt .Printf (" %9.3f %9.3f %9.3f\n " , p50IngestionMs , p95IngestionMs , p99IngestionMs )
168+ fmt .Printf ("################## GRAPH STATS ##################\n " )
169+ fmt .Printf ("Total Empty resultsets %d ( %3.3f %%)\n " , totalEmptyResultsets , float64 (totalEmptyResultsets / totalCommands * 100.0 ))
170+ fmt .Printf ("Total Nodes created %d\n " , totalNodesCreated )
171+ fmt .Printf ("Total Nodes deleted %d\n " , totalNodesDeleted )
172+ fmt .Printf ("Total Labels added %d\n " , totalLabelsAdded )
173+ fmt .Printf ("Total Properties set %d\n " , totalPropertiesSet )
174+ fmt .Printf ("Total Relationships created %d\n " , totalRelationshipsCreated )
175+ fmt .Printf ("Total Relationships deleted %d\n " , totalRelationshipsDeleted )
141176 fmt .Printf ("Overall RedisGraph Internal Execution time Latency summary (msec):\n " )
142177 fmt .Printf (" %9s %9s %9s\n " , "p50" , "p95" , "p99" )
143178 fmt .Printf (" %9.3f %9.3f %9.3f\n " , graph_p50IngestionMs , graph_p95IngestionMs , graph_p99IngestionMs )
0 commit comments