diff --git a/mbed_greentea/mbed_report_api.py b/mbed_greentea/mbed_report_api.py index 6b722a77..33b44c74 100644 --- a/mbed_greentea/mbed_report_api.py +++ b/mbed_greentea/mbed_report_api.py @@ -775,6 +775,10 @@ def exporter_memory_metrics_csv(test_result_ext, test_suite_properties=None): report_key = '%s_%s_max_heap_usage' % (target_name, test_suite_name) metrics_report[report_key] = memory_metrics['max_heap'] + if 'reserved_heap' in memory_metrics: + report_key = '%s_%s_reserved_heap_usage' % (target_name, test_suite_name) + metrics_report[report_key] = memory_metrics['reserved_heap'] + if 'thread_stack_summary' in memory_metrics: thread_stack_summary = memory_metrics['thread_stack_summary'] @@ -790,7 +794,11 @@ def exporter_memory_metrics_csv(test_result_ext, test_suite_properties=None): report_key = '%s_%s_max_stack_usage_total' % (target_name, test_suite_name) metrics_report[report_key] = thread_stack_summary['max_stack_usage_total'] + if 'reserved_stack_total' in thread_stack_summary: + report_key = '%s_%s_reserved_stack_total' % (target_name, test_suite_name) + metrics_report[report_key] = thread_stack_summary['reserved_stack_total'] + column_names = sorted(metrics_report.keys()) column_values = [str(metrics_report[x]) for x in column_names] - return "%s\n%s" % (','.join(column_names), ','.join(column_values)) \ No newline at end of file + return "%s\n%s" % (','.join(column_names), ','.join(column_values)) diff --git a/mbed_greentea/mbed_test_api.py b/mbed_greentea/mbed_test_api.py index cd0295f8..8debae2b 100644 --- a/mbed_greentea/mbed_test_api.py +++ b/mbed_greentea/mbed_test_api.py @@ -301,7 +301,7 @@ def get_binary_host_tests_dir(binary_path, level=2): result = get_test_result(htrun_output) result_test_cases = get_testcase_result(htrun_output) test_cases_summary = get_testcase_summary(htrun_output) - max_heap, thread_stack_info = get_memory_metrics(htrun_output) + max_heap, reserved_heap, thread_stack_info = get_memory_metrics(htrun_output) thread_stack_summary = [] @@ -310,6 +310,7 @@ def get_binary_host_tests_dir(binary_path, level=2): memory_metrics = { "max_heap": max_heap, + "reserved_heap": reserved_heap, "thread_stack_info": thread_stack_info, "thread_stack_summary": thread_stack_summary } @@ -523,8 +524,10 @@ def get_memory_metrics(output): is a list of dictionaries with format {entry, arg, max_stack, stack_size} """ max_heap_usage = None + reserved_heap = None thread_info = {} re_tc_max_heap_usage = re.compile(r"^\[(\d+\.\d+)\][^\{]+\{\{(max_heap_usage);(\d+)\}\}") + re_tc_reserved_heap = re.compile(r"^\[(\d+\.\d+)\][^\{]+\{\{(reserved_heap);(\d+)\}\}") re_tc_thread_info = re.compile(r"^\[(\d+\.\d+)\][^\{]+\{\{(__thread_info);\"([A-Fa-f0-9\-xX]+)\",(\d+),(\d+)\}\}") for line in output.splitlines(): m = re_tc_max_heap_usage.search(line) @@ -532,6 +535,11 @@ def get_memory_metrics(output): _, _, max_heap_usage = m.groups() max_heap_usage = int(max_heap_usage) + m = re_tc_reserved_heap.search(line) + if m: + _, _, reserved_heap = m.groups() + reserved_heap = int(reserved_heap) + m = re_tc_thread_info.search(line) if m: _, _, thread_entry_arg, thread_max_stack, thread_stack_size = m.groups() @@ -552,18 +560,21 @@ def get_memory_metrics(output): thread_info_list = thread_info.values() - return max_heap_usage, thread_info_list + return max_heap_usage, reserved_heap, thread_info_list def get_thread_with_max_stack_size(thread_stack_info): max_thread_stack_size = 0 max_thread = None max_stack_usage_total = 0 + reserved_stack_total = 0 for cur_thread_stack_info in thread_stack_info: if cur_thread_stack_info['stack_size'] > max_thread_stack_size: max_thread_stack_size = cur_thread_stack_info['stack_size'] max_thread = cur_thread_stack_info max_stack_usage_total += cur_thread_stack_info['max_stack'] + reserved_stack_total += cur_thread_stack_info['stack_size'] max_thread['max_stack_usage_total'] = max_stack_usage_total + max_thread['reserved_stack_total'] = reserved_stack_total return max_thread def get_thread_stack_info_summary(thread_stack_info): @@ -572,7 +583,8 @@ def get_thread_stack_info_summary(thread_stack_info): summary = { 'max_stack_size': max_thread_info['stack_size'], 'max_stack_usage': max_thread_info['max_stack'], - 'max_stack_usage_total': max_thread_info['max_stack_usage_total'] + 'max_stack_usage_total': max_thread_info['max_stack_usage_total'], + 'reserved_stack_total': max_thread_info['reserved_stack_total'] } return summary