diff options
-rw-r--r-- | qtip/reporter/console.py | 4 | ||||
-rw-r--r-- | qtip/reporter/templates/base.j2 | 32 | ||||
-rw-r--r-- | qtip/reporter/templates/dpi.j2 | 9 | ||||
-rw-r--r-- | qtip/reporter/templates/ramspeed.j2 | 25 | ||||
-rw-r--r-- | qtip/reporter/templates/ssl.j2 | 37 | ||||
-rw-r--r-- | qtip/reporter/templates/unixbench.j2 | 21 | ||||
-rw-r--r-- | tests/unit/cli/cmd_report_test.py | 64 | ||||
-rw-r--r-- | tests/unit/reporter/console_test.py | 55 |
8 files changed, 114 insertions, 133 deletions
diff --git a/qtip/reporter/console.py b/qtip/reporter/console.py index cb51d9c9..da04930f 100644 --- a/qtip/reporter/console.py +++ b/qtip/reporter/console.py @@ -10,10 +10,11 @@ import glob import json from os import path - from jinja2 import Environment from jinja2 import FileSystemLoader + from qtip.base import BaseActor +from qtip.reporter import filters ROOT_DIR = path.join(path.dirname(__file__), path.pardir, path.pardir) @@ -28,6 +29,7 @@ class ConsoleReporter(BaseActor): tpl_path = path.join(path.dirname(__file__), 'templates') tpl_loader = FileSystemLoader(tpl_path) self._env = Environment(loader=tpl_loader) + self._env.filters['justify'] = filters.justify def load_result(self, result_path): result_dirs = glob.glob('{}/qtip-*'.format(result_path)) diff --git a/qtip/reporter/templates/base.j2 b/qtip/reporter/templates/base.j2 index 12a27536..34242b40 100644 --- a/qtip/reporter/templates/base.j2 +++ b/qtip/reporter/templates/base.j2 @@ -1,9 +1,11 @@ -Plan Name: {{ plan_name }} -Start Time: {{ start_time }} -Stop Time: {{ stop_time }} -{%- for sys in sut -%} +{{ '=' * 100}} +{{ ('Plan Name', plan_name)|justify }} +{{ ('Start Time', start_time)|justify }} +{{ ('Stop Time', stop_time)|justify }} +{% for sys in sut %} +{{ '\033[92m' }} {{ sys.name }} {{ '\033[0m' }} {% for qpi in sys.qpis %} -{% for bm in qpi.benchmarks %} +{%- for bm in qpi.benchmarks -%} {%- if bm.name == metric_name -%} {%- if metric_name == 'dhrystone' or metric_name == 'whetstone' -%} {# TODO (taseer) remove hardcoded material #} @@ -11,15 +13,17 @@ Stop Time: {{ stop_time }} {% 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 }} +System Information +{{ ('CPU Brand', bm.sysinfo.cpu)|justify }} +{{ ('Disk', bm.sysinfo.disk)|justify }} +{{ ('Host Name', bm.sysinfo.hostname)|justify }} +{{ ('Kernel', bm.sysinfo.kernel)|justify }} +{{ ('Memory', bm.sysinfo.memory)|justify }} +{{ ('Operating System', bm.sysinfo.os)|justify }} +{{ ('Product', bm.sysinfo.product)|justify }} {%- endif -%} {%- endfor -%} -{%- endfor -%} +{% endfor %} + +{{ '\033[93m' }} {{ '*' * 100}} {{ '\033[0m' }} {%- endfor -%} diff --git a/qtip/reporter/templates/dpi.j2 b/qtip/reporter/templates/dpi.j2 index 758a821e..552a03e8 100644 --- a/qtip/reporter/templates/dpi.j2 +++ b/qtip/reporter/templates/dpi.j2 @@ -1,5 +1,4 @@ -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 +{{ ('Benchmark', bm.name)|justify }} +{{ ('CPU Usage', bm.cpu_usage)|justify }} +{{ ('Bits per Second', bm.results.bps)|justify }} +{{ ('Packets per Second', bm.results.pps)|justify }} diff --git a/qtip/reporter/templates/ramspeed.j2 b/qtip/reporter/templates/ramspeed.j2 index d08d7e2e..8ad17821 100644 --- a/qtip/reporter/templates/ramspeed.j2 +++ b/qtip/reporter/templates/ramspeed.j2 @@ -1,13 +1,12 @@ -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 +{{ ('Benchmark', bm.name)|justify }} +{{ ('CPU Usage', bm. cpu_usage)|justify }} +{{ ('Float Addition', bm.results.float_add)|justify }} +{{ ('Float Average', bm.results.float_average)|justify }} +{{ ('Float Copy', bm.results.float_copy)|justify }} +{{ ('Float Scale', bm.results.float_scale)|justify }} +{{ ('Float Triad', bm.results.float_triad)|justify }} +{{ ('Integer Addition', bm.results.integer_add)|justify }} +{{ ('Integer Average', bm.results.integer_average)|justify }} +{{ ('Integer Copy', bm.results.integer_copy)|justify }} +{{ ('Integer Scale', bm.results.integer_scale)|justify }} +{{ ('Integer Triad', bm.results.integer_triad)|justify}} diff --git a/qtip/reporter/templates/ssl.j2 b/qtip/reporter/templates/ssl.j2 index b46927a8..44ee3891 100644 --- a/qtip/reporter/templates/ssl.j2 +++ b/qtip/reporter/templates/ssl.j2 @@ -1,21 +1,20 @@ -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 }} +{{ ('Benchmark', bm.name)|justify }} +{{ ('CPU Usage', bm.cpu_usage)|justify }} +AES 128 CBC (bytes) +{{ ('16', bm.results.aes_128_cbc_16_bytes)|justify }} +{{ ('64', bm.results.aes_128_cbc_64_bytes)|justify }} +{{ ('256', bm.results.aes_128_cbc_256_bytes)|justify }} +{{ ('1024', bm.results.aes_128_cbc_1024_bytes)|justify }} +{{ ('8192', bm.results.aes_128_cbc_8192_bytes)|justify }} - 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 SIGN +{{ ('512', bm.results.rsa_sign_512)|justify }} +{{ ('1024', bm.results.rsa_sign_1024)|justify }} +{{ ('2048', bm.results.rsa_sign_2048)|justify }} +{{ ('4096', bm.results.rsa_sign_4096)|justify }} - 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 +RSA VERIFY +{{ ('512', bm.results.rsa_verify_512)|justify }} +{{ ('1024', bm.results.rsa_verify_1024)|justify }} +{{ ('2048', bm.results.rsa_verify_2048)|justify }} +{{ ('4096', bm.results.rsa_verify_4096)|justify }} diff --git a/qtip/reporter/templates/unixbench.j2 b/qtip/reporter/templates/unixbench.j2 index 69006da7..a3ff2a3b 100644 --- a/qtip/reporter/templates/unixbench.j2 +++ b/qtip/reporter/templates/unixbench.j2 @@ -1,10 +1,11 @@ -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 +{{ ('Benchmark', bm.name)|justify }} +{{ ('CPU Usage', bm. cpu_usage)|justify }} + +Multi CPU +{{ ('Number', bm.results.multi_cpus.num)|justify }} +{{ ('Score', bm.results.multi_cpus.score)|justify }} + +Single CPU +{{ ('Number', bm.results.single_cpu.num)|justify }} +{{ ('Score', bm.results.single_cpu.score)|justify }} +{{ ('Total CPUs', bm.results.total_cpus)|justify }}
\ No newline at end of file diff --git a/tests/unit/cli/cmd_report_test.py b/tests/unit/cli/cmd_report_test.py index 9263707f..21e757d8 100644 --- a/tests/unit/cli/cmd_report_test.py +++ b/tests/unit/cli/cmd_report_test.py @@ -30,70 +30,56 @@ def test_dhrystone(runner, result_path): """Test dhrystone report""" result = runner.invoke(cli, ['report', 'show', 'dhrystone', '-p', result_path]) - assert "Benchmark: dhrystone" in result.output - assert "CPU Usage: 3%" in result.output - assert "Number: 40" in result.output - assert "Score: 63529.6" in result.output - assert "Single CPU:" in result.output - assert "Total CPUs: 40" in result.output + assert "Benchmark..............................................................." \ + "...................dhrystone" in result.output + assert "Score..................................................................." \ + "..................63529.6" def test_whetstone(runner, result_path): """ Test whetstone output""" result = runner.invoke(cli, ['report', 'show', 'whetstone', '-p', result_path]) - assert "Benchmark: whetstone" in result.output - assert "CPU Usage: 3%" in result.output - assert "Results:" in result.output - assert "Multi CPU:" in result.output - assert "Number: 40" in result.output - assert "Score: 21198.3" in result.output - assert "Single CPU:" in result.output + assert "Number................................................................." \ + "...........................40" in result.output + assert "Total CPUs............................................................." \ + "...........................40" def test_dpi(runner, result_path): """ Test dpi report""" result = runner.invoke(cli, ['report', 'show', 'dpi', '-p', result_path]) - assert "Benchmark: dpi" in result.output - assert "CPU Usage: 3%" in result.output - assert "Bits per Second: 3.638" in result.output - assert "Packets per Second: 1.45" in result.output - assert "Bits per Second: 3.69" in result.output - assert "Packets per Second: 1.458" in result.output + assert "Bits per Second..................................................." \ + ".............................3.638" in result.output + assert "Packets per Second................................................" \ + ".............................1.458" in result.output def test_ramspeed(runner, result_path): """ Test ramspeed report """ result = runner.invoke(cli, ['report', 'show', 'ramspeed', '-p', result_path]) - assert "Benchmark: ramspeed" in result.output - assert "CPU Usage: 3%" in result.output - assert "Float Addition: 10217.62" in result.output - assert "Float Average: 9176.88" in result.output - assert "Float Copy: 8127.13" in result.output - assert "Float Scale: 8085.40" in result.output - assert "Float Triad: 10277.38" in result.output - assert "Integer Addition: 11471.63" in result.output - assert "Integer Average: 11396.35" in result.output + assert "Float Addition........................................................" \ + "......................10522.33" in result.output + assert "Integer Average........................................................" \ + ".....................11466.52" in result.output def test_ssl(runner, result_path): """ Test ssl report""" result = runner.invoke(cli, ['report', 'show', 'ssl', '-p', result_path]) - assert "Benchmark: ssl" in result.output - assert "CPU Usage: 3%" in result.output - assert "AES 128 CBC (bytes):" in result.output - assert "256: 584951.30k" in result.output - assert "RSA SIGN:" in result.output - assert "2048: 9.9" in result.output - assert "RSA VERIFY:" in result.output - assert "4096: 7688.5" in result.output + assert "8192............................................................." \ + ".........................667303.94k" in result.output + assert "1024.............................................................." \ + "..........................100088.3" in result.output def test_sys(runner, result_path): """ Test sys_info """ result = runner.invoke(cli, ['report', 'show', 'ssl', '-p', result_path]) - assert "System Information:" in result.output - assert "Host Name: node-38.zte.com.cn" in result.output - assert "Memory: 4403.7/128524.1MB" in result.output + assert "System Information" in result.output + assert "Host Name........................................................" \ + ".................node-38.zte.com.cn" in result.output + assert "Operating System.................................................." \ + "...............Ubuntu 16.04 xenial" in result.output diff --git a/tests/unit/reporter/console_test.py b/tests/unit/reporter/console_test.py index 037ef2fb..7ece4663 100644 --- a/tests/unit/reporter/console_test.py +++ b/tests/unit/reporter/console_test.py @@ -33,65 +33,56 @@ def test_dhrystone(console_reporter, result_path): """ Test dhrystone report""" result = console_reporter.render('dhrystone', result_path) - assert "Benchmark: dhrystone" in result - assert "Number: 40" in result - assert "Score: 63529.6" in result - assert "Single CPU:" in result - assert "Total CPUs: 40" in result + assert "Benchmark..............................................................." \ + "...................dhrystone" in result def test_whetstone(console_reporter, result_path): """ Test whetstone output""" result = console_reporter.render('whetstone', result_path) - assert "Benchmark: whetstone" in result - assert "Results:" in result - assert "Multi CPU:" in result - assert "Number: 40" in result - assert "Score: 21198.3" in result - assert "Single CPU:" in result + assert "Number................................................................." \ + "...........................40" in result + assert "Total CPUs............................................................." \ + "...........................40" in result def test_dpi(console_reporter, result_path): """ Test dpi report""" result = console_reporter.render('dpi', result_path) - assert "Benchmark: dpi" in result - assert "Bits per Second: 3.638" in result - assert "Packets per Second: 1.45" in result - assert "Bits per Second: 3.69" in result - assert "Packets per Second: 1.458" in result + assert "Bits per Second..................................................." \ + ".............................3.638" in result + assert "Packets per Second................................................" \ + ".............................1.458" in result def test_ramspeed(console_reporter, result_path): """ Test ramspeed report """ result = console_reporter.render('ramspeed', result_path) - assert "Float Addition: 10217.62" in result - assert "Float Average: 9176.88" in result - assert "Float Copy: 8127.13" in result - assert "Float Scale: 8085.40" in result - assert "Float Triad: 10277.38" in result - assert "Integer Addition: 11471.63" in result - assert "Integer Average: 11396.35" in result + assert "Float Addition........................................................" \ + "......................10522.33" in result + assert "Integer Average........................................................" \ + ".....................11466.52" in result def test_ssl(console_reporter, result_path): """ Test ssl report""" result = console_reporter.render('ssl', result_path) - assert "AES 128 CBC (bytes):" in result - assert "256: 584951.30k" in result - assert "RSA SIGN:" in result - assert "2048: 9.9" in result - assert "RSA VERIFY:" in result - assert "4096: 7688.5" in result + assert "8192............................................................." \ + ".........................667303.94k" in result + assert "1024.............................................................." \ + "..........................100088.3" in result def test_sys(console_reporter, result_path): """ Test sys_info """ result = console_reporter.render('ssl', result_path) - assert "System Information:" in result - assert "Host Name: node-38.zte.com.cn" in result - assert "Memory: 4403.7/128524.1MB" in result + assert "System Information" in result + assert "Host Name........................................................" \ + ".................node-38.zte.com.cn" in result + assert "Operating System.................................................." \ + "...............Ubuntu 16.04 xenial" in result |