Lines Matching refs:self

55             self,  argument
72 self.version = version
73 self.git_rev = git_rev
74 self.arch = arch
75 self.config = config
76 self.compiler = compiler
77 self.opt_level = opt_level
79 self.pre_make_cmd = [] #type: typing.List[str]
80 self.make_cmd = ''
82 def get_info_indication(self): argument
84 return '{git_rev}-{arch}-{config}-{compiler}'.format(**self.__dict__)
90 self, argument
98 self.host_arch = host_arch
99 self.measure_cmd = measure_cmd
101 def get_info_indication(self): argument
104 .format(measure_tool=self.measure_cmd.strip().split(' ')[0])
109 self, argument
125 self.record_dir = record_dir
126 self.comp_dir = comp_dir
127 self.with_markdown = with_markdown
128 self.stdout = stdout
129 self.show_all = show_all
171 self, argument
188 self.arch = size_dist_info.arch
189 self.config = size_dist_info.config
190 self.compiler = size_dist_info.compiler
191 self.opt_level = size_dist_info.opt_level
193 self.make_cmd = ['make', '-j', 'lib']
195 self.host_arch = host_arch
196 self.logger = logger
198 def check_correctness(self) -> bool: argument
203 if self.config == SupportedConfig.DEFAULT.value and \
204 self.arch == self.host_arch:
207 elif self.arch == SupportedArch.ARMV8_M.value and \
208 self.config == SupportedConfig.TFM_MEDIUM.value:
213 def infer_pre_make_command(self) -> typing.List[str]: argument
216 if self.config == SupportedConfig.TFM_MEDIUM.value:
225 def infer_make_cflags(self) -> str: argument
230 cflags.append(self.opt_level)
232 if self.config == SupportedConfig.TFM_MEDIUM.value:
233 self.compiler = 'armclang'
236 if self.compiler == 'armclang':
241 def infer_make_command(self) -> str: argument
244 if self.check_correctness():
246 self.make_cmd.append('CFLAGS=\'{}\''.format(self.infer_make_cflags()))
248 self.make_cmd.append('CC={}'.format(self.compiler))
249 return ' '.join(self.make_cmd)
251 self.logger.error("Unsupported combination of architecture: {} " \
253 .format(self.arch,
254 self.config))
255 self.logger.error("Please use supported combination of " \
258 self.logger.error(comb)
259 self.logger.error("")
260 self.logger.error("For your system, please use:")
262 if "default" in comb and self.host_arch not in comb:
264 self.logger.error(comb)
274 self, argument
288 self.repo_path = "."
289 self.git_command = "git"
290 self.make_clean = 'make clean'
292 self.git_rev = git_rev
293 self.pre_make_cmd = pre_make_cmd
294 self.make_cmd = make_cmd
295 self.measure_cmd = measure_cmd
296 self.logger = logger
305 def _create_git_worktree(self) -> str: argument
309 if self.git_rev == 'current':
310 self.logger.debug("Using current work directory.")
311 git_worktree_path = self.repo_path
313 self.logger.debug("Creating git worktree for {}."
314 .format(self.git_rev))
315 git_worktree_path = os.path.join(self.repo_path,
316 "temp-" + self.git_rev)
318 [self.git_command, "worktree", "add", "--detach",
319 git_worktree_path, self.git_rev], cwd=self.repo_path,
335 def _build_libraries(self, git_worktree_path: str) -> None: argument
338 self.logger.debug("Building library/*.o for {}."
339 .format(self.git_rev))
342 if self.git_rev == 'current':
343 self.backup_config_files(restore=False)
344 for pre_cmd in self.pre_make_cmd:
351 self.make_clean, env=my_environment, shell=True,
356 self.make_cmd, env=my_environment, shell=True,
360 if self.git_rev == 'current':
361 self.backup_config_files(restore=True)
363 self._handle_called_process_error(e, git_worktree_path)
365 def _gen_raw_code_size(self, git_worktree_path: str) -> typing.Dict[str, str]: argument
368 self.logger.debug("Measuring code size for {} by `{}`."
369 .format(self.git_rev,
370 self.measure_cmd.strip().split(' ')[0]))
376 [self.measure_cmd + ' ' + st_lib], cwd=git_worktree_path,
381 self._handle_called_process_error(e, git_worktree_path)
385 def _remove_worktree(self, git_worktree_path: str) -> None: argument
387 if git_worktree_path != self.repo_path:
388 self.logger.debug("Removing temporary worktree {}."
391 [self.git_command, "worktree", "remove", "--force",
392 git_worktree_path], cwd=self.repo_path,
396 def _handle_called_process_error(self, e: subprocess.CalledProcessError, argument
402 self.logger.error(e, exc_info=True)
403 self.logger.error("Process output:\n {}".format(e.output))
406 self._remove_worktree(git_worktree_path)
409 def cal_libraries_code_size(self) -> typing.Dict[str, str]: argument
417 git_worktree_path = self._create_git_worktree()
419 self._build_libraries(git_worktree_path)
420 res = self._gen_raw_code_size(git_worktree_path)
422 self._remove_worktree(git_worktree_path)
434 def __init__(self, logger: logging.Logger) -> None: argument
438 self.logger = logger
441 self, argument
458 self, argument
483 def __init__(self, text: int, data: int, bss: int, dec: int): argument
484 self.text = text
485 self.data = data
486 self.bss = bss
487 self.total = dec # total <=> dec
489 def __init__(self, logger: logging.Logger) -> None: argument
505 self.code_size = {} #type: typing.Dict[str, typing.Dict]
506 self.mod_total_suffix = '-' + 'TOTALS'
508 def _set_size_record(self, git_rev: str, mod: str, size_text: str) -> None: argument
517 data[5] = mod + self.mod_total_suffix
521 self.code_size.setdefault(git_rev, {}).update({mod: size_record})
523 def read_size_record(self, git_rev: str, fname: str) -> None: argument
544 m = re.match(r'\w+' + self.mod_total_suffix, line)
546 if git_rev in self.code_size:
547 self.code_size[git_rev].update({mod: size_record})
549 self.code_size[git_rev] = {mod: size_record}
554 self, argument
564 self._set_size_record(git_rev, mod, size_text)
570 for mod, f_size in self.code_size[git_rev].items():
579 self, argument
692 for fname, size_entry in self.code_size[old_rev][mod].items():
694 for fname, size_entry in self.code_size[new_rev][mod].items():
697 mod_total_sz = f_rev_size.pop(mod + self.mod_total_suffix)
699 total_clm = get_results({mod + self.mod_total_suffix: mod_total_sz})
714 self, argument
734 self.logger = logger
736 self.old_size_dist_info = old_size_dist_info
737 self.new_size_dist_info = new_size_dist_info
738 self.size_common_info = size_common_info
740 self.old_size_dist_info.pre_make_cmd = CodeSizeBuildInfo(
741 self.old_size_dist_info, self.size_common_info.host_arch,
742 self.logger).infer_pre_make_command()
743 self.new_size_dist_info.pre_make_cmd = CodeSizeBuildInfo(
744 self.new_size_dist_info, self.size_common_info.host_arch,
745 self.logger).infer_pre_make_command()
747 self.old_size_dist_info.make_cmd = CodeSizeBuildInfo(
748 self.old_size_dist_info, self.size_common_info.host_arch,
749 self.logger).infer_make_command()
750 self.new_size_dist_info.make_cmd = CodeSizeBuildInfo(
751 self.new_size_dist_info, self.size_common_info.host_arch,
752 self.logger).infer_make_command()
754 self.code_size_generator = self.__generate_size_parser()
756 self.result_options = result_options
757 self.csv_dir = os.path.abspath(self.result_options.record_dir)
758 os.makedirs(self.csv_dir, exist_ok=True)
759 self.comp_dir = os.path.abspath(self.result_options.comp_dir)
760 os.makedirs(self.comp_dir, exist_ok=True)
762 def __generate_size_parser(self): argument
764 if re.match(r'size', self.size_common_info.measure_cmd.strip()):
765 return CodeSizeGeneratorWithSize(self.logger)
767 self.logger.error("Unsupported measurement tool: `{}`."
768 .format(self.size_common_info.measure_cmd
773 self, argument
781 self.size_common_info.measure_cmd,
782 self.logger).cal_libraries_code_size()
784 def gen_code_size_report(self, size_dist_info: CodeSizeDistinctInfo) -> None: argument
787 self.logger.info("Start to generate code size record for {}."
790 self.csv_dir,
793 self.size_common_info.get_info_indication()))
797 self.logger.debug("Code size csv file for {} already exists."
799 self.code_size_generator.read_size_record(
803 code_size_text = self.cal_code_size(size_dist_info)
805 self.logger.debug("Generating code size csv for {}."
808 self.code_size_generator.write_record(
811 def gen_code_size_comparison(self) -> None: argument
820 self.logger.info("Start to generate comparision result between "\
822 .format(self.old_size_dist_info.git_rev,
823 self.new_size_dist_info.git_rev))
824 if self.result_options.stdout:
828 self.comp_dir,
830 .format(self.old_size_dist_info.get_info_indication(),
831 self.new_size_dist_info.get_info_indication(),
832 self.size_common_info.get_info_indication(),
833 'md' if self.result_options.with_markdown else 'csv'))
836 self.logger.debug("Generating comparison results between {} and {}."
837 .format(self.old_size_dist_info.git_rev,
838 self.new_size_dist_info.git_rev))
839 if self.result_options.with_markdown or self.result_options.stdout:
841 .format(self.old_size_dist_info.get_info_indication(),
842 self.new_size_dist_info.get_info_indication(),
843 self.size_common_info.get_info_indication()),
845 self.code_size_generator.write_comparison(
846 self.old_size_dist_info.git_rev,
847 self.new_size_dist_info.git_rev,
848 output, self.result_options.with_markdown,
849 self.result_options.show_all)
851 def get_comparision_results(self) -> None: argument
855 self.gen_code_size_report(self.old_size_dist_info)
856 self.gen_code_size_report(self.new_size_dist_info)
857 self.gen_code_size_comparison()