Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
demonolock merged 1 commit intomasterfrommeasuring_the_speed_of_commands
May 28, 2024

Conversation

MakSl
Copy link
Contributor

This will be useful to keep track of possible performance degradation when code changes.

@MakSlMakSl requested a review fromdemonolockMay 22, 2024 12:48
stderr=subprocess.STDOUT,
env=env
).decode('utf-8', errors='replace')
if execution_time:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Думаю ничего страшного, если будем замерять время команд всегда

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Хмм, получается будем замерять всегда, но будем использовать не всегда?
Может лучше оставим условие? Хоть замер и не занимает много времени. Но читаемость кода так лучше имхо.

Copy link
Contributor

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_time

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

В конечной реализации это доп условие и вправду лишнее.


def run(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):
Copy link
Contributor

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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Поправил

@demonolock
Copy link
Contributor

Проблема со стилем кода

Можно проверять локально поставив flake8
Установка
pip install flake8

Проверка
flake8 /путь/до_кода

MakSl reacted with thumbs up emoji

@MakSlMakSlforce-pushed themeasuring_the_speed_of_commands branch from7049fa7 to0dc237dCompareMay 22, 2024 23:35
elapsed_time_4t = backup_id_4t.execution_time

# Full by basebackup
backup = node.backup(check_time=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

А тест проверял? Проходит?
Не вижу check_time в функции backup_node

Copy link
ContributorAuthor

@MakSlMakSlMay 28, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Данный тест был не работоспособен. Исправил его и проверил у себя. Получение времени осуществляется.

Отдельный тест на проверку работоспособности считаю излишней. Поэтому по итогу убрал тест.

@@ -56,6 +56,7 @@ def __init__(self, test_class: unittest.TestCase,
self.verbose = init_params.verbose
self.archive_compress = init_params.archive_compress
self.test_class.output = None
self.execution_time = execution_time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Так лучше не делать
execution_time и признак того что мы хотим замерить время и само время.
Python конечно позволяет, но это ведет к сложноотслеживаемым ошибкам. Лучше сделать его None если замера не было

Copy link
ContributorAuthor

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.
@MakSlMakSlforce-pushed themeasuring_the_speed_of_commands branch from0dc237d tob452e0dCompareMay 28, 2024 14:36
@demonolockdemonolock merged commit63db275 intomasterMay 28, 2024
2 checks passed
@demonolockdemonolock deleted the measuring_the_speed_of_commands branchMay 28, 2024 15:07
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@demonolockdemonolockdemonolock approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@MakSl@demonolock

[8]ページ先頭

©2009-2025 Movatter.jp