Skip to content

Commit a94faa4

Browse files
committed
[add] simplified FinalizeReport
1 parent 9f4bdd6 commit a94faa4

File tree

1 file changed

+43
-31
lines changed
  • benchmark/redisgraph

1 file changed

+43
-31
lines changed

benchmark/redisgraph/kn.py

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
# acknowledgement to TigerGraph.
99
# Author: Mingxi Wu mingxi.wu@tigergraph.com
1010
############################################################
11-
11+
import argparse
1212
import multiprocessing
1313
import os
1414
import sys
1515
from timeit import default_timer as timer
1616

17-
import click
18-
1917
from query_runner import *
2018

2119
# Global, map of reports.
@@ -36,8 +34,7 @@ def InitSeedReports(seeds, iterations):
3634
#####################################################################
3735
# Generate a report summary.
3836
#######################################################################
39-
def FinalizeReport(unique_node_file, depth, threads):
40-
global seedReports
37+
def FinalizeReport(seedReports, unique_node_file, depth, threads):
4138
# seed=19284, k=1, runId=0, avgNeighbor=91.0, execTime=0.197093009949
4239
# AVG Seed iterations.
4340

@@ -47,24 +44,14 @@ def FinalizeReport(unique_node_file, depth, threads):
4744
threadsTotalRuntime = [0] * threads
4845
runs = 0
4946

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-
5947
for seed in seedReports:
60-
seed_raw = raw_seeds[int(seed)]
6148
report = seedReports[seed]
6249
for iterationReport in report:
6350
avgNeighbor = iterationReport['avgN']
6451
execTime = iterationReport['totalTime']
6552
threadId = iterationReport['threadId']
6653
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)
6855
output += "**************************************************************\r\n"
6956

7057
avgKNSize += avgNeighbor
@@ -156,19 +143,8 @@ def RunKNLatencyThread(datadir, graphid, threadId, depth, provider, label, seedP
156143
# function: check the total latency for k-hop-path neighbor count
157144
# query for a given set of seeds.
158145
################################################################
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+
172148
def RunKNLatency(data_dir, graphid, count, depth, provider, label, threads, iterations, url, seed, stdout):
173149
# create result folder
174150
global seedReports
@@ -218,7 +194,8 @@ def RunKNLatency(data_dir, graphid, count, depth, provider, label, threads, iter
218194

219195
print("Finalizing report")
220196
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)
222199

223200
if stdout is False:
224201

@@ -239,4 +216,39 @@ def RunKNLatency(data_dir, graphid, count, depth, provider, label, threads, iter
239216

240217

241218
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

Comments
 (0)