Fix bugs in benchmarks

Reviewers: buda

Reviewed By: buda

Differential Revision: https://phabricator.memgraph.io/D536
This commit is contained in:
Mislav Bradac 2017-07-11 14:43:26 +02:00
parent d14accad07
commit 955962d036
3 changed files with 14 additions and 13 deletions

View File

@ -9,17 +9,17 @@ BATCH_SIZE = 50
def create_vertices(vertex_count): def create_vertices(vertex_count):
for vertex in range(vertex_count): for vertex in range(vertex_count):
print("CREATE (:Label {id: %d})" % vertex) print("CREATE (:Label {id: %d})" % vertex)
if vertex != 0 and vertex % BATCH_SIZE == 0: if (vertex != 0 and vertex % BATCH_SIZE == 0) or \
(vertex + 1 == vertex_count):
print(";") print(";")
def create_edges(edge_count, vertex_count): def create_edges(edge_count, vertex_count):
""" vertex_count is the number of already existing vertices in graph """ """ vertex_count is the number of already existing vertices in graph """
for edge in range(edge_count): for edge in range(edge_count):
print("MERGE ({id: %d})-[:Type]->({id: %d})" % ( print("MATCH (a {id: %d}), (b {id: %d}) MERGE (a)-[:Type]->(b)" % (
randint(0, vertex_count - 1), randint(0, vertex_count - 1))) randint(0, vertex_count - 1), randint(0, vertex_count - 1)))
if edge != 0 and edge % BATCH_SIZE == 0: print(";")
print(";")
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -54,17 +54,17 @@ def main():
# create vertices # create vertices
for vertex_index in range(VERTEX_COUNT): for vertex_index in range(VERTEX_COUNT):
print("CREATE %s" % vertex(vertex_index)) print("CREATE %s" % vertex(vertex_index))
if vertex_index != 0 and vertex_index % BATCH_SIZE == 0: if (vertex_index != 0 and vertex_index % BATCH_SIZE == 0) or \
vertex_index + 1 == VERTEX_COUNT:
print(";") print(";")
# create edges # create edges
for edge_index in range(EDGE_COUNT): for edge_index in range(EDGE_COUNT):
print("MERGE (a%d {%s: %d})-%s->(b%d {%s: %d})" % ( print("MATCH (a {%s: %d}), (b {%s: %d}) MERGE (a)-%s->(b)" % (
edge_index, ID, randint(0, VERTEX_COUNT - 1), ID, randint(0, VERTEX_COUNT - 1),
edge(edge_index), ID, randint(0, VERTEX_COUNT - 1),
edge_index, ID, randint(0, VERTEX_COUNT - 1))) edge(edge_index)))
if edge_index != 0 and edge_index % BATCH_SIZE == 0: print(";")
print(";")
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -57,7 +57,7 @@ def main():
argp = ArgumentParser("Bolt client execution process") argp = ArgumentParser("Bolt client execution process")
# positional args # positional args
argp.add_argument("db_uri") argp.add_argument("db_uri")
argp.add_argument("queries", nargs="+") argp.add_argument("queries", nargs="*")
# named, optional # named, optional
argp.add_argument("--encrypt", action="store_true") argp.add_argument("--encrypt", action="store_true")
@ -88,7 +88,8 @@ def main():
_print_dict({ _print_dict({
RETURN_CODE: 0, RETURN_CODE: 0,
WALL_TIME: delta_time / float(len(args.queries)), WALL_TIME: (None if not args.queries else
delta_time / float(len(args.queries))),
"metadatas": metadatas "metadatas": metadatas
}) })