- Notifications
You must be signed in to change notification settings - Fork36
Added command execution time measurement#123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| stderr=subprocess.STDOUT, | ||
| env=env | ||
| ).decode('utf-8',errors='replace') | ||
| ifexecution_time: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Думаю ничего страшного, если будем замерять время команд всегда
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Хмм, получается будем замерять всегда, но будем использовать не всегда?
Может лучше оставим условие? Хоть замер и не занимает много времени. Но читаемость кода так лучше имхо.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Почему читаемость лучше?
if self.execution_time: start_time = time.time() self.test_class.output = subprocess.check_output( cmdline, stderr=subprocess.STDOUT, env=env ).decode('utf-8', errors='replace') end_time = time.time() self.execution_time = end_time - start_time else: self.test_class.output = subprocess.check_output( cmdline, stderr=subprocess.STDOUT, env=env ).decode('utf-8', errors='replace')против
start_time = time.time() self.test_class.output = subprocess.check_output( cmdline, stderr=subprocess.STDOUT, env=env ).decode('utf-8', errors='replace') end_time = time.time() self.execution_time = end_time - start_timeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
В конечной реализации это доп условие и вправду лишнее.
| defrun(self,command,gdb=False,old_binary=False,return_id=True,env=None, | ||
| skip_log_directory=False,expect_error=False,use_backup_dir=True): | ||
| skip_log_directory=False,expect_error=False,use_backup_dir=True,execution_time=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
прокидывать сюда не нужно было, execution_time и так доступен из self.execution_time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Поправил
demonolock commentedMay 22, 2024
Проблема со стилем кода
Можно проверять локально поставив flake8 Проверка |
7049fa7 to0dc237dComparetestgres/performance_test.py Outdated
| elapsed_time_4t=backup_id_4t.execution_time | ||
| # Full by basebackup | ||
| backup=node.backup(check_time=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
А тест проверял? Проходит?
Не вижу check_time в функции backup_node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Данный тест был не работоспособен. Исправил его и проверил у себя. Получение времени осуществляется.
Отдельный тест на проверку работоспособности считаю излишней. Поэтому по итогу убрал тест.
| self.verbose=init_params.verbose | ||
| self.archive_compress=init_params.archive_compress | ||
| self.test_class.output=None | ||
| self.execution_time=execution_time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Так лучше не делать
execution_time и признак того что мы хотим замерить время и само время.
Python конечно позволяет, но это ведет к сложноотслеживаемым ошибкам. Лучше сделать его None если замера не было
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Согласен. Исправил этот момент.
This will be useful to keep track of possible performance degradation when code changes.
0dc237d tob452e0dCompare
This will be useful to keep track of possible performance degradation when code changes.