9
9
10
10
import sys
11
11
import os
12
- import threading
13
12
import click
14
13
import multiprocessing
15
14
from query_runner import *
18
17
# Global, map of reports.
19
18
seedReports = {}
20
19
20
+
21
21
#####################################################################
22
22
# Initialize seed reporting,
23
23
# seedReports[seed][iterations] contains the number of iterations required for seed
@@ -28,10 +28,11 @@ def InitSeedReports(seeds, iterations):
28
28
for s in seeds :
29
29
seedReports [s ] = []
30
30
31
+
31
32
#####################################################################
32
33
# Generate a report summary.
33
34
#######################################################################
34
- def FinalizeReport (depth , threads ):
35
+ def FinalizeReport (graphid , depth , threads ):
35
36
global seedReports
36
37
# seed=19284, k=1, runId=0, avgNeighbor=91.0, execTime=0.197093009949
37
38
# AVG Seed iterations.
@@ -42,14 +43,21 @@ def FinalizeReport(depth, threads):
42
43
threadsTotalRuntime = [0 ] * threads
43
44
runs = 0
44
45
46
+ # map to raw seed id
47
+ raw_seeds = []
48
+ if os .path .exists (graphid + '_unique_node' ):
49
+ for line in open (graphid + '_unique_node' ):
50
+ raw_seeds .append (line .strip ())
51
+
45
52
for seed in seedReports :
53
+ seed_raw = raw_seeds [int (seed )]
46
54
report = seedReports [seed ]
47
55
for iterationReport in report :
48
56
avgNeighbor = iterationReport ['avgN' ]
49
57
execTime = iterationReport ['totalTime' ]
50
58
threadId = iterationReport ['threadId' ]
51
59
threadsTotalRuntime [threadId ] += execTime
52
- output += "seed=%s, k=%d, avgNeighbor=%d, execTime=%f[ms]\r \n " % (seed , depth , avgNeighbor , execTime )
60
+ output += "seed=%s, k=%d, avgNeighbor=%d, execTime=%f[ms]\r \n " % (seed_raw , depth , avgNeighbor , execTime )
53
61
output += "**************************************************************\r \n "
54
62
55
63
avgKNSize += avgNeighbor
@@ -69,6 +77,7 @@ def FinalizeReport(depth, threads):
69
77
70
78
return output
71
79
80
+
72
81
#####################################################################
73
82
# K-hop-path-neighbor-count benchmark workload.
74
83
# (1) read prepared random nodes from a seed file under seed folder.
@@ -87,6 +96,7 @@ def GetSeeds(seed_file_path, count):
87
96
print ("Seed file does not contain enough seeds." )
88
97
sys .exit ()
89
98
99
+
90
100
###############################################################
91
101
# function: thread worker, pull work item from pool
92
102
# and execute query via runner
@@ -97,7 +107,7 @@ def RunKNLatencyThread(graphid, threadId, depth, provider, label, seedPool, repo
97
107
elif provider == "tigergraph" :
98
108
runner = TigerGraphQueryRunner ()
99
109
else :
100
- print "Unknown runner %s, quiting" % provider
110
+ print ( "Unknown runner %s, quiting" % provider )
101
111
sys .exit ()
102
112
103
113
# As long as there's work to do...
@@ -132,23 +142,24 @@ def RunKNLatencyThread(graphid, threadId, depth, provider, label, seedPool, repo
132
142
iterationSummary ['totalTime' ] = iterationTime
133
143
reportQueue .put (iterationSummary , False )
134
144
145
+
135
146
###############################################################
136
147
# function: check the total latency for k-hop-path neighbor count
137
148
# query for a given set of seeds.
138
149
################################################################
139
150
@click .command ()
140
- @click .option ('--graphid' , '-g' , default = 'graph500' , help = "graph id" )
141
- @ click .option ( '--seedfile ' , '-s' , default = './seeds' , help = "seed file " )
151
+ @click .option ('--graphid' , '-g' , default = 'graph500-22' ,
152
+ type = click .Choice ([ 'graph500-22 ' , 'twitter_rv_net' ]), help = "graph id " )
142
153
@click .option ('--count' , '-c' , default = 20 , help = "number of seeds" )
143
154
@click .option ('--depth' , '-d' , default = 1 , help = "number of hops to perform" )
144
155
@click .option ('--provider' , '-p' , default = 'redisgraph' , help = "graph identifier" )
145
156
@click .option ('--label' , '-l' , default = 'label' , help = "node label" )
146
157
@click .option ('--threads' , '-t' , default = 2 , help = "number of querying threads" )
147
158
@click .option ('--iterations' , '-i' , default = 10 , help = "number of iterations per query" )
148
- def RunKNLatency (graphid , seedfile , count , depth , provider , label , threads , iterations ):
159
+ def RunKNLatency (graphid , count , depth , provider , label , threads , iterations ):
149
160
#create result folder
150
161
global seedReports
151
-
162
+ seedfile = os . path . join ( 'data' , graphid + '-seed' )
152
163
seeds = GetSeeds (seedfile , count )
153
164
154
165
# Create a pool of seeds.
@@ -188,7 +199,7 @@ def RunKNLatency(graphid, seedfile, count, depth, provider, label, threads, iter
188
199
seedReports [seed ].append ({'avgN' : avgN , 'totalTime' : totalTime , 'threadId' : threadId })
189
200
190
201
print ("Finalizing report" )
191
- output = FinalizeReport (depth , threads )
202
+ output = FinalizeReport (graphid , depth , threads )
192
203
dirName = "./result_" + provider + "/"
193
204
fileName = "KN-latency-k%d-threads%d-iter%d" % (depth , threads , iterations )
194
205
outputPath = os .path .join (dirName , fileName )
0 commit comments