Added max memory usage to harness
Reviewers: buda, mislav.bradac Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D790
This commit is contained in:
parent
d116e0deb1
commit
84b0d03a5f
@ -3,7 +3,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import tempfile
|
import tempfile
|
||||||
from common import get_absolute_path, WALL_TIME, CPU_TIME
|
from common import get_absolute_path, WALL_TIME, CPU_TIME, MAX_MEMORY
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -56,7 +56,8 @@ class QueryClient:
|
|||||||
# TODO make the timeout configurable per query or something
|
# TODO make the timeout configurable per query or something
|
||||||
return_code = self.client.run_and_wait(
|
return_code = self.client.run_and_wait(
|
||||||
client, client_args, timeout=600, stdin=queries_path)
|
client, client_args, timeout=600, stdin=queries_path)
|
||||||
cpu_time_end = database.database_bin.get_usage()["cpu"]
|
usage = database.database_bin.get_usage()
|
||||||
|
cpu_time_end = usage["cpu"]
|
||||||
os.remove(queries_path)
|
os.remove(queries_path)
|
||||||
if return_code != 0:
|
if return_code != 0:
|
||||||
with open(self.client.get_stderr()) as f:
|
with open(self.client.get_stderr()) as f:
|
||||||
@ -69,6 +70,7 @@ class QueryClient:
|
|||||||
with open(output) as f:
|
with open(output) as f:
|
||||||
data = json.loads(f.read())
|
data = json.loads(f.read())
|
||||||
data[CPU_TIME] = cpu_time_end - cpu_time_start
|
data[CPU_TIME] = cpu_time_end - cpu_time_start
|
||||||
|
data[MAX_MEMORY] = usage["max_memory"]
|
||||||
|
|
||||||
os.remove(output)
|
os.remove(output)
|
||||||
return data
|
return data
|
||||||
|
@ -2,6 +2,7 @@ import os
|
|||||||
|
|
||||||
WALL_TIME = "wall_time"
|
WALL_TIME = "wall_time"
|
||||||
CPU_TIME = "cpu_time"
|
CPU_TIME = "cpu_time"
|
||||||
|
MAX_MEMORY = "max_memory"
|
||||||
|
|
||||||
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
|
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from argparse import ArgumentParser
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import tempfile
|
import tempfile
|
||||||
from statistics import median
|
from statistics import median
|
||||||
from common import get_absolute_path, WALL_TIME, CPU_TIME
|
from common import get_absolute_path, WALL_TIME, CPU_TIME, MAX_MEMORY
|
||||||
from databases import Memgraph, Neo
|
from databases import Memgraph, Neo
|
||||||
from clients import QueryClient
|
from clients import QueryClient
|
||||||
|
|
||||||
@ -25,12 +25,12 @@ class _QuerySuite:
|
|||||||
KNOWN_KEYS = {"config", "setup", "itersetup", "run", "iterteardown",
|
KNOWN_KEYS = {"config", "setup", "itersetup", "run", "iterteardown",
|
||||||
"teardown", "common"}
|
"teardown", "common"}
|
||||||
FORMAT = ["{:>24}", "{:>28}", "{:>16}", "{:>18}", "{:>22}",
|
FORMAT = ["{:>24}", "{:>28}", "{:>16}", "{:>18}", "{:>22}",
|
||||||
"{:>16}", "{:>16}"]
|
"{:>16}", "{:>16}", "{:>16}"]
|
||||||
FULL_FORMAT = "".join(FORMAT) + "\n"
|
FULL_FORMAT = "".join(FORMAT) + "\n"
|
||||||
summary = FULL_FORMAT.format(
|
summary = FULL_FORMAT.format(
|
||||||
"group_name", "scenario_name", "parsing_time",
|
"group_name", "scenario_name", "parsing_time",
|
||||||
"planning_time", "plan_execution_time",
|
"planning_time", "plan_execution_time",
|
||||||
WALL_TIME, CPU_TIME)
|
WALL_TIME, CPU_TIME, MAX_MEMORY)
|
||||||
|
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
pass
|
pass
|
||||||
@ -93,6 +93,7 @@ class _QuerySuite:
|
|||||||
scenario_config.get("num_client_workers", 1))
|
scenario_config.get("num_client_workers", 1))
|
||||||
add_measurement(run_result, iteration, WALL_TIME)
|
add_measurement(run_result, iteration, WALL_TIME)
|
||||||
add_measurement(run_result, iteration, CPU_TIME)
|
add_measurement(run_result, iteration, CPU_TIME)
|
||||||
|
add_measurement(run_result, iteration, MAX_MEMORY)
|
||||||
for measurement in ["parsing_time",
|
for measurement in ["parsing_time",
|
||||||
"plan_execution_time",
|
"plan_execution_time",
|
||||||
"planning_time"] :
|
"planning_time"] :
|
||||||
@ -114,12 +115,17 @@ class _QuerySuite:
|
|||||||
self.summary += self.FORMAT[0].format(group_name)
|
self.summary += self.FORMAT[0].format(group_name)
|
||||||
self.summary += self.FORMAT[1].format(scenario_name)
|
self.summary += self.FORMAT[1].format(scenario_name)
|
||||||
for i, key in enumerate(("parsing_time", "planning_time",
|
for i, key in enumerate(("parsing_time", "planning_time",
|
||||||
"plan_execution_time", WALL_TIME, CPU_TIME)):
|
"plan_execution_time", WALL_TIME, CPU_TIME, MAX_MEMORY)):
|
||||||
if key not in measurement_lists:
|
if key not in measurement_lists:
|
||||||
time = "-"
|
time = "-"
|
||||||
else:
|
else:
|
||||||
|
fmt = "{:.10f}"
|
||||||
# Median is used instead of avg to avoid effect of outliers.
|
# Median is used instead of avg to avoid effect of outliers.
|
||||||
time = "{:.10f}".format(median(measurement_lists[key]))
|
value = median(measurement_lists[key])
|
||||||
|
if key == MAX_MEMORY:
|
||||||
|
fmt = "{}"
|
||||||
|
value = int(value)
|
||||||
|
time = fmt.format(value)
|
||||||
self.summary += self.FORMAT[i + 2].format(time)
|
self.summary += self.FORMAT[i + 2].format(time)
|
||||||
self.summary += "\n"
|
self.summary += "\n"
|
||||||
|
|
||||||
|
@ -51,20 +51,28 @@ def compare_values(data_cur, data_prev):
|
|||||||
item = " ".join(item_cur.split("_")).capitalize()
|
item = " ".join(item_cur.split("_")).capitalize()
|
||||||
else:
|
else:
|
||||||
item_prev = find_item(data_prev, headers[j], row_cur)
|
item_prev = find_item(data_prev, headers[j], row_cur)
|
||||||
|
if j != len(row_cur) - 1:
|
||||||
|
fmt = "{:.3f}ms"
|
||||||
|
scale = 1000.0
|
||||||
|
else:
|
||||||
|
fmt = "{:.2f}MiB"
|
||||||
|
scale = 1.0 / 1024.0
|
||||||
if item_prev != None:
|
if item_prev != None:
|
||||||
if item_prev != 0.0:
|
if item_prev != 0.0:
|
||||||
diff = (item_cur - item_prev) / item_prev
|
diff = (item_cur - item_prev) / item_prev
|
||||||
else:
|
else:
|
||||||
diff = 0.0
|
diff = 0.0
|
||||||
if diff < -0.05:
|
if diff < -0.05 and item_cur > 0.0005:
|
||||||
sign = " {icon arrow-down color=green}"
|
sign = " {icon arrow-down color=green}"
|
||||||
elif diff > 0.05:
|
elif diff > 0.05 and item_cur > 0.0005:
|
||||||
sign = " {icon arrow-up color=red}"
|
sign = " {icon arrow-up color=red}"
|
||||||
else:
|
else:
|
||||||
sign = ""
|
sign = ""
|
||||||
item = "{:.3f}ms //({:+.2%})//{}".format(item_cur * 1000.0, diff, sign)
|
fmt += " //({:+.2%})//{}"
|
||||||
|
item = fmt.format(item_cur * scale, diff, sign)
|
||||||
else:
|
else:
|
||||||
item = "{:.3f}ms //(new)// {{icon plus color=blue}}".format(item_cur * 1000.0)
|
fmt += "//(new)// {{icon plus color=blue}}"
|
||||||
|
item = fmt.format(item_cur * scale)
|
||||||
ret[i].append(item)
|
ret[i].append(item)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user