summaryrefslogtreecommitdiffstats
path: root/qtip
diff options
context:
space:
mode:
authorTaseer <taseer94@gmail.com>2017-03-09 12:05:46 +0500
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-03-21 09:09:10 +0000
commit19dd4962baca5d7103fe0de55d415e175dbe35e4 (patch)
treeab416a88be6066a0faefbf6f3d86f0a9d05a3044 /qtip
parent695a881515c40e29fc12eb5003e0f3682bc4d64b (diff)
Refactor reporter module
- Create templates for report format specific to each metric. - Outputs the details of the specified metric across all the nodes in cluster. - Timeline to be covered in a separate patch JIRA: QTIP-199 Change-Id: Ic83749725b0c9cc5bd9a7f24f21b2cd113abe0e1 Signed-off-by: Taseer Ahmed <taseer94@gmail.com> (cherry picked from commit 04e50e57819bdf40a2fd7abdd3fc7be798771e0b)
Diffstat (limited to 'qtip')
-rw-r--r--qtip/cli/commands/cmd_report.py8
-rw-r--r--qtip/reporter/console.py34
-rw-r--r--qtip/reporter/templates/base.j226
-rw-r--r--qtip/reporter/templates/dpi.j25
-rw-r--r--qtip/reporter/templates/ramspeed.j213
-rw-r--r--qtip/reporter/templates/report.j222
-rw-r--r--qtip/reporter/templates/ssl.j221
-rw-r--r--qtip/reporter/templates/timeline.j24
-rw-r--r--qtip/reporter/templates/unixbench.j210
9 files changed, 108 insertions, 35 deletions
diff --git a/qtip/cli/commands/cmd_report.py b/qtip/cli/commands/cmd_report.py
index c780e847..cb9c70b6 100644
--- a/qtip/cli/commands/cmd_report.py
+++ b/qtip/cli/commands/cmd_report.py
@@ -10,6 +10,7 @@
import click
from qtip.cli.entry import Context
+from qtip.reporter.console import ConsoleReporter
pass_context = click.make_pass_decorator(Context, ensure=False)
@@ -22,6 +23,9 @@ def cli(ctx):
@cli.command('show')
+@click.argument('metric')
@pass_context
-def show(ctx):
- pass
+def show(ctx, metric):
+ reporter = ConsoleReporter({})
+ report = reporter.render(metric)
+ click.echo(report)
diff --git a/qtip/reporter/console.py b/qtip/reporter/console.py
index 2b5130a6..64d677ba 100644
--- a/qtip/reporter/console.py
+++ b/qtip/reporter/console.py
@@ -7,24 +7,40 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import glob
+import json
+from os import path
+
from jinja2 import Environment
from jinja2 import FileSystemLoader
-from os import path
from qtip.base import BaseActor
+ROOT_DIR = path.join(path.dirname(__file__), path.pardir, path.pardir)
+
class ConsoleReporter(BaseActor):
- """
- report benchmark result to console
- """
+ """ report benchmark result to console """
+
def __init__(self, config, parent=None):
super(ConsoleReporter, self).__init__(config, parent=parent)
# TODO (taseer) load template from config
- tpl_loader = FileSystemLoader(path.join(path.dirname(__file__), 'templates'))
- env = Environment(loader=tpl_loader)
- self._template = env.get_template('timeline.j2')
+ tpl_path = path.join(path.dirname(__file__), 'templates')
+ tpl_loader = FileSystemLoader(tpl_path)
+ self._env = Environment(loader=tpl_loader)
+ self.result_path = path.join(ROOT_DIR, 'collector')
+
+ def load_result(self):
+ # TODO (taseer) change result directory format more suitable to filter out
+ result_dirs = glob.glob('{}/20*'.format(self.result_path))
+ # select the last (latest) directory for rendering report, result_dirs[-1]
+ with open(path.join(self.result_path, result_dirs[-1], 'result.json')) as sample:
+ result = json.load(sample)
+ return result
- def render(self, var_dict):
- out = self._template.render(var_dict)
+ def render(self, metric):
+ template = self._env.get_template('base.j2')
+ var_dict = self.load_result()
+ var_dict['metric_name'] = metric
+ out = template.render(var_dict)
return out
diff --git a/qtip/reporter/templates/base.j2 b/qtip/reporter/templates/base.j2
new file mode 100644
index 00000000..26697175
--- /dev/null
+++ b/qtip/reporter/templates/base.j2
@@ -0,0 +1,26 @@
+Plan Name: {{ plan_name }}
+Start Time: {{ start_time }}
+Stop Time: {{ stop_time }}
+{%- for sys in sut -%}
+{% for qpi in sys.qpis %}
+{% for bm in qpi.benchmarks %}
+{%- if bm.name == metric_name -%}
+{%- if metric_name == 'dhrystone' or metric_name == 'whetstone' -%}
+{# TODO (taseer) remove hardcoded material #}
+{% include 'unixbench.j2' %}
+{% else %}
+{% include '%s.j2' % metric_name %}
+{%- endif -%}
+
+System Information:
+ CPU Brand: {{ bm.sysinfo.cpu }}
+ Disk: {{ bm.sysinfo.disk }}
+ Host Name: {{ bm.sysinfo.hostname }}
+ Kernel: {{ bm.sysinfo.kernel }}
+ Memory: {{ bm.sysinfo.memory }}
+ Operating System: {{ bm.sysinfo.os }}
+ Product: {{ bm.sysinfo.product }}
+{%- endif -%}
+{%- endfor -%}
+{%- endfor -%}
+{%- endfor -%} \ No newline at end of file
diff --git a/qtip/reporter/templates/dpi.j2 b/qtip/reporter/templates/dpi.j2
new file mode 100644
index 00000000..758a821e
--- /dev/null
+++ b/qtip/reporter/templates/dpi.j2
@@ -0,0 +1,5 @@
+Benchmark: {{ bm.name }}
+CPU Usage: {{ bm. cpu_usage }}
+Results:
+ Bits per Second: {{ bm.results.bps }}
+ Packets per Second: {{ bm.results.pps }} \ No newline at end of file
diff --git a/qtip/reporter/templates/ramspeed.j2 b/qtip/reporter/templates/ramspeed.j2
new file mode 100644
index 00000000..d08d7e2e
--- /dev/null
+++ b/qtip/reporter/templates/ramspeed.j2
@@ -0,0 +1,13 @@
+Benchmark: {{ bm.name }}
+CPU Usage: {{ bm. cpu_usage }}
+Results:
+ Float Addition: {{ bm.results.float_add }}
+ Float Average: {{ bm.results.float_average }}
+ Float Copy: {{ bm.results.float_copy }}
+ Float Scale: {{ bm.results.float_scale }}
+ Float Triad: {{ bm.results.float_triad }}
+ Integer Addition: {{ bm.results.integer_add }}
+ Integer Average: {{ bm.results.integer_average }}
+ Integer Copy: {{ bm.results.integer_copy}}
+ Integer Scale: {{ bm.results.integer_scale }}
+ Integer Triad: {{ bm.results.integer_triad}} \ No newline at end of file
diff --git a/qtip/reporter/templates/report.j2 b/qtip/reporter/templates/report.j2
deleted file mode 100644
index 766e6dde..00000000
--- a/qtip/reporter/templates/report.j2
+++ /dev/null
@@ -1,22 +0,0 @@
-{{ title }}
-
-Plan: {{ plan.name }}
-
-{{ qpi.name }}: {{ qpi.score }}
-Sections:
-{% for section in sections %}
- {{ section.name }}: {{ section.score }}
-
- Formula: {{ section.formula }}
- Metrics:
- {% for metric in section.metrics %}
- {{ metric.name }}: {{ metric.score }}
- Formula: {{ metric.formula }}
- Workloads:
- {% for workload in workloads %}
- {{ workload.name }}: {{ workload.score }}
- {% endfor %}
- {% endfor %}
-{% endfor %}
-
-{{ signature }}
diff --git a/qtip/reporter/templates/ssl.j2 b/qtip/reporter/templates/ssl.j2
new file mode 100644
index 00000000..b46927a8
--- /dev/null
+++ b/qtip/reporter/templates/ssl.j2
@@ -0,0 +1,21 @@
+Benchmark: {{ bm.name }}
+CPU Usage: {{ bm.cpu_usage }}
+Results:
+ AES 128 CBC (bytes):
+ 16: {{ bm.results.aes_128_cbc_16_bytes }}
+ 64: {{ bm.results.aes_128_cbc_64_bytes }}
+ 256: {{ bm.results.aes_128_cbc_256_bytes }}
+ 1024: {{ bm.results.aes_128_cbc_1024_bytes }}
+ 8192: {{ bm.results.aes_128_cbc_8192_bytes }}
+
+ RSA SIGN:
+ 512: {{ bm.results.rsa_sign_512 }}
+ 1024: {{ bm.results.rsa_sign_1024 }}
+ 2048: {{ bm.results.rsa_sign_2048 }}
+ 4096: {{ bm.results.rsa_sign_4096 }}
+
+ RSA VERIFY:
+ 512: {{ bm.results.rsa_verify_512 }}
+ 1024: {{ bm.results.rsa_verify_1024 }}
+ 2048: {{ bm.results.rsa_verify_2048 }}
+ 4096: {{ bm.results.rsa_verify_4096 }} \ No newline at end of file
diff --git a/qtip/reporter/templates/timeline.j2 b/qtip/reporter/templates/timeline.j2
index d4c95c46..ccb089e0 100644
--- a/qtip/reporter/templates/timeline.j2
+++ b/qtip/reporter/templates/timeline.j2
@@ -1,8 +1,8 @@
{{ title }}
{% for phase in phases %}
-{{ phase.name|upper }}{{ "TIME" }}
+{{ phase.name|upper }}{{ "TIME"}}
{% for cp in phase.checkpoints %}
-{{ cp.name }}{{ cp.timestamp}}
+{{ cp.name }}{{ cp.timestamp| indent(15, True)}}
{% endfor %}
{% endfor %}
Total: {{ total }}
diff --git a/qtip/reporter/templates/unixbench.j2 b/qtip/reporter/templates/unixbench.j2
new file mode 100644
index 00000000..69006da7
--- /dev/null
+++ b/qtip/reporter/templates/unixbench.j2
@@ -0,0 +1,10 @@
+Benchmark: {{ bm.name }}
+CPU Usage: {{ bm. cpu_usage }}
+Results:
+ Multi CPU:
+ Number: {{ bm.results.multi_cpus.num }}
+ Score: {{ bm.results.multi_cpus.score }}
+ Single CPU:
+ Number: {{ bm.results.single_cpu.num }}
+ Score: {{ bm.results.single_cpu.num }}
+ Total CPUs: {{ bm.results.total_cpus }} \ No newline at end of file