-
Notifications
You must be signed in to change notification settings - Fork 50
[Yaroslavzev] #43
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[Yaroslavzev] #43
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Оптимизация времени выполнения тестов | ||
|
||
Для оптимизации был выбран рабочий проект. | ||
|
||
Тест сьют рабочего проекта выполняется на 5 параллельных воркерах и | ||
среднее время выполнения тестов составляет 17 минут. | ||
|
||
Вывод результатов тестов указывает 10 самых медленных тестов и 10 самых медленных групп тестов. | ||
Собственно, точками роста были взяты медленные тесты и группы тестов. | ||
|
||
Основным интрументом для оптимизации был FactoryProf из пакета`test-prof`. | ||
Анализ тестов FactoryProf показал, что большинство тестов выполняются медленно из-за создания ассоциаций. | ||
Для ускорения создания ассоциаций было внесены изменения в фабрики как на примере ниже: | ||
```ruby | ||
factory :user do | ||
account { Account.first || create(:account) } | ||
end | ||
``` | ||
Из интересного было обнаружено, что Resolv.getaddress(host) занимает до 20 секунд на выполнение, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. У нас проект хостится в k8s и у нас есть сервис, который собирает трейсы от разных API endpoint-ов. |
||
и правильный мок метода позволил ускорить выполнение тестов. | ||
|
||
После оптимизации тестов среднее время выполнения тестов 12 минут. | ||
Таким образом, скорость выполнения тестов ускорена на 40 процентов. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
в таких случаях ещё можно any_fixture использовать
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.
спасибо за предложение. Добавить решение выше оказалось проще, потому что меньше правок вносить в кодовую базу