8
8
# acknowledgement to TigerGraph.
9
9
# Author: Mingxi Wu mingxi.wu@tigergraph.com
10
10
############################################################
11
-
11
+ import argparse
12
12
import multiprocessing
13
13
import os
14
14
import sys
15
15
from timeit import default_timer as timer
16
16
17
- import click
18
-
19
17
from query_runner import *
20
18
21
19
# Global, map of reports.
@@ -36,8 +34,7 @@ def InitSeedReports(seeds, iterations):
36
34
#####################################################################
37
35
# Generate a report summary.
38
36
#######################################################################
39
- def FinalizeReport (unique_node_file , depth , threads ):
40
- global seedReports
37
+ def FinalizeReport (seedReports , unique_node_file , depth , threads ):
41
38
# seed=19284, k=1, runId=0, avgNeighbor=91.0, execTime=0.197093009949
42
39
# AVG Seed iterations.
43
40
@@ -47,24 +44,14 @@ def FinalizeReport(unique_node_file, depth, threads):
47
44
threadsTotalRuntime = [0 ] * threads
48
45
runs = 0
49
46
50
- # map to raw seed id
51
- raw_seeds = []
52
- if not os .path .exists (unique_node_file ):
53
- print ("Unique node file does not exists: " + unique_node_file )
54
- sys .exit ()
55
-
56
- for line in open (unique_node_file ):
57
- raw_seeds .append (line .strip ())
58
-
59
47
for seed in seedReports :
60
- seed_raw = raw_seeds [int (seed )]
61
48
report = seedReports [seed ]
62
49
for iterationReport in report :
63
50
avgNeighbor = iterationReport ['avgN' ]
64
51
execTime = iterationReport ['totalTime' ]
65
52
threadId = iterationReport ['threadId' ]
66
53
threadsTotalRuntime [threadId ] += execTime
67
- output += "seed=%s, k=%d, avgNeighbor=%d, execTime=%f[ms]\r \n " % (seed_raw , depth , avgNeighbor , execTime )
54
+ output += "seed=%s, k=%d, avgNeighbor=%d, execTime=%f[ms]\r \n " % (seed , depth , avgNeighbor , execTime )
68
55
output += "**************************************************************\r \n "
69
56
70
57
avgKNSize += avgNeighbor
@@ -156,19 +143,8 @@ def RunKNLatencyThread(datadir, graphid, threadId, depth, provider, label, seedP
156
143
# function: check the total latency for k-hop-path neighbor count
157
144
# query for a given set of seeds.
158
145
################################################################
159
- @click .command ()
160
- @click .option ('--graphid' , '-g' , default = 'graph500_22' ,
161
- type = click .Choice (['graph500_22' , 'twitter_rv_net' ]), help = "graph id" )
162
- @click .option ('--count' , '-c' , default = 1 , help = "number of seeds" )
163
- @click .option ('--depth' , '-d' , default = 1 , help = "number of hops to perform" )
164
- @click .option ('--provider' , '-p' , default = 'redisgraph' , help = "graph identifier" )
165
- @click .option ('--url' , '-u' , default = '127.0.0.1:6379' , help = "DB url" )
166
- @click .option ('--label' , '-l' , default = 'graph500_22_unique_node' , help = "node label" )
167
- @click .option ('--seed' , '-s' , default = 'seed' , help = "seed file" )
168
- @click .option ('--data_dir' , default = 'data' , help = "data dir" )
169
- @click .option ('--threads' , '-t' , default = 1 , help = "number of querying threads" )
170
- @click .option ('--iterations' , '-i' , default = 1 , help = "number of iterations per query" )
171
- @click .option ('--stdout' , type = bool , default = True , help = "print report to stdout" )
146
+
147
+
172
148
def RunKNLatency (data_dir , graphid , count , depth , provider , label , threads , iterations , url , seed , stdout ):
173
149
# create result folder
174
150
global seedReports
@@ -218,7 +194,8 @@ def RunKNLatency(data_dir, graphid, count, depth, provider, label, threads, iter
218
194
219
195
print ("Finalizing report" )
220
196
unique_node_file = os .path .join (data_dir , label )
221
- output = FinalizeReport (unique_node_file , depth , threads )
197
+ print unique_node_file
198
+ output = FinalizeReport (seedReports , unique_node_file , depth , threads )
222
199
223
200
if stdout is False :
224
201
@@ -239,4 +216,39 @@ def RunKNLatency(data_dir, graphid, count, depth, provider, label, threads, iter
239
216
240
217
241
218
if __name__ == '__main__' :
242
- RunKNLatency ()
219
+ parser = argparse .ArgumentParser (description = "check the total latency for k-hop-path neighbor count." )
220
+ parser .add_argument (
221
+ "--graphid" , "-g" , type = str , default = 'graph500_22' , help = "graph id"
222
+ )
223
+ parser .add_argument (
224
+ "--count" , "-c" , type = int , default = 1 , help = "number of seeds"
225
+ )
226
+ parser .add_argument (
227
+ "--depth" , "-d" , type = int , default = 1 , help = "number of hops to perform"
228
+ )
229
+ parser .add_argument (
230
+ "--provider" , "-p" , type = str , default = "redisgraph" , help = "graph identifier"
231
+ )
232
+ parser .add_argument (
233
+ "--url" , "-u" , type = str , default = "127.0.0.1:6379" , help = "DB url"
234
+ )
235
+ parser .add_argument (
236
+ "--label" , "-l" , type = str , default = "graph500_22_unique_node" , help = "node label"
237
+ )
238
+ parser .add_argument (
239
+ "--seed" , "-s" , type = str , default = "seed" , help = "seed file"
240
+ )
241
+ parser .add_argument (
242
+ "--data_dir" , type = str , default = "data" , help = "data dir"
243
+ )
244
+ parser .add_argument (
245
+ "--threads" , "-t" , type = int , default = 1 , help = "number of querying threads"
246
+ )
247
+ parser .add_argument (
248
+ "--iterations" , "-i" , type = int , default = 1 , help = "number of iterations per query"
249
+ )
250
+ parser .add_argument ('--stdout' , type = bool , default = True , help = "print report to stdout" )
251
+
252
+ args = parser .parse_args ()
253
+ RunKNLatency (args .data_dir , args .graphid , args .count , args .depth , args .provider , args .label , args .threads ,
254
+ args .iterations , args .url , args .seed , args .stdout )
0 commit comments