-
Notifications
You must be signed in to change notification settings - Fork 46
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
Task_7 (iL53n) #25
Open
iL53n
wants to merge
1
commit into
hardcode-dev:master
Choose a base branch
from
iL53n:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+130
−0
Open
Task_7 (iL53n) #25
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Задание 7 - Оптимизация DX | ||
[ССЫЛКА НА PR С ИЗМЕНЕНИЯМИ В КОДОВОЙ БАЗЕ](https://github.com/iL53n/ekt_library/pull/48) | ||
|
||
## Начальные значения | ||
Первый прогон тестов | ||
```bash | ||
Finished in 2 minutes 8.4 seconds (files took 1.84 seconds to load) | ||
177 examples, 0 failures, 5 pending | ||
Coverage report generated for RSpec to /home/il53n/Desktop/ekt_library/coverage. 1657 / 1677 LOC (98.81%) covered. | ||
``` | ||
Для себя установил **БЮДЖЕТ** в **40сек**, т.е. в 3 раза быстрее. | ||
|
||
## 1 | ||
Установил гем `parallel-tests`, запустил локально в 3 потока, результат порадовал: | ||
```bash | ||
Finished in 1 minute 31.17 seconds (files took 2.23 seconds to load) | ||
177 examples, 0 failures, 5 pendings | ||
Coverage report generated for (1/3), (2/3), (3/3) to /home/il53n/Desktop/ekt_library/coverage. 1491 / 1509 LOC (98.81%) covered. | ||
``` | ||
## 2 | ||
Отключил логирование. Результат: | ||
```bash | ||
Finished in 1 minute 17.62 seconds (files took 2.86 seconds to load) | ||
177 examples, 0 failures, 5 pendings | ||
Coverage report generated for (1/3), (2/3), (3/3) to /home/il53n/Desktop/ekt_library/coverage. 1493 / 1511 LOC (98.81%) covered. | ||
``` | ||
## 3 | ||
Отключил `database_cleaner`, часть тестов упало. | ||
Не разбирался, вернусь позже если не смогу другими точками роста выполнить бюджет. | ||
|
||
```bash | ||
# 1 прогон | ||
177 examples, 25 failures, 5 pendings | ||
# 2 прогон | ||
177 examples, 137 failures, 5 pendings | ||
``` | ||
## 4 | ||
Попробовал в работе `rspec --profile`, `ruby_prof`, `stack_prof`, поковырялся в отчете в `speedscope`, в отчете `kcachegrind`... пока больше цель ставил попробовать данные инструменты с тестами. | ||
|
||
Везде глаза "мазолил" `database_cleaner`, так что еще не успев забыть возвращаюсь с данному вопросу (отключение гема). | ||
![](data/1.png) | ||
![](data/2.png) | ||
в общем решил вернуться к вопросу удачного прогона тестов без database_cleaner. Отключил, результат: | ||
|
||
```bash | ||
Finished in 1 minute 9.8 seconds (files took 2.47 seconds to load) | ||
177 examples, 0 failures, 5 pendings | ||
Coverage report generated for (1/3), (2/3), (3/3), RSpec to /home/il53n/Desktop/ekt_library/coverage. 1651 / 1673 LOC (98.68%) covered. | ||
``` | ||
## 5 | ||
След инструмент `dissect` показал: | ||
|
||
```bash | ||
[TEST PROF INFO] RSpecDissect report | ||
|
||
Total time: 01:43.117 | ||
|
||
Total `let` time: 00:02.716 | ||
Total `before(:each)` time: 00:51.494 | ||
``` | ||
|
||
я бы сказал, что с `let` проблем нет, а вот с `before` надо бы поработать | ||
|
||
Добавил где возможно `let_it_be`, для `before_all` применения не нашел. | ||
![](data/3.png) | ||
Но вот в отчете обратил внимание на хелпер, который сам когда-то писал для этого проекта (зачем? непонятно) `sign_in`. Отключил его, добавил стандартные методы с `devise`... | ||
Итого результаты порадовали, очень близок к бюджету: | ||
|
||
```bash | ||
Finished in 41.89 seconds (files took 2.46 seconds to load) | ||
172 examples, 0 failures | ||
Coverage report generated for (1/3), (2/3), (3/3), RSpec to /home/il53n/Desktop/ekt_library/coverage. 1477 / 1497 LOC (98.66%) covered. | ||
``` | ||
|
||
```bash | ||
[TEST PROF INFO] RSpecDissect report | ||
|
||
Total time: 00:59.819 | ||
|
||
Total `let` time: 00:00.275 | ||
Total `before(:each)` time: 00:09.151 | ||
``` | ||
## 6 | ||
Заюзал `FactoryProf` | ||
```bash | ||
[TEST PROF INFO] Factories usage | ||
|
||
Total: 257 | ||
Total top-level: 215 | ||
Total time: 00:01.749 (out of 00:59.346) | ||
Total uniq factories: 7 | ||
|
||
total top-level total time time per call top-level time name | ||
|
||
130 105 1.1031s 0.0085s 0.9451s user | ||
64 50 0.3334s 0.0052s 0.2804s book | ||
31 31 0.3095s 0.0100s 0.3095s post | ||
21 18 0.1069s 0.0051s 0.0820s category | ||
6 6 0.0561s 0.0093s 0.0561s comment | ||
4 4 0.0481s 0.0120s 0.0481s rating | ||
1 1 0.0279s 0.0279s 0.0279s book_with_categories | ||
``` | ||
Больших проблем не увидел, но несколько моментов поправил. Итог: | ||
|
||
```bash | ||
Total: 248 | ||
Total top-level: 216 | ||
Total time: 00:01.504 (out of 01:02.003) | ||
Total uniq factories: 7 | ||
|
||
total top-level total time time per call top-level time name | ||
|
||
125 105 1.0085s 0.0081s 0.8893s user | ||
60 51 0.2287s 0.0038s 0.2031s book | ||
31 31 0.2073s 0.0067s 0.2073s post | ||
21 18 0.1219s 0.0058s 0.0940s category | ||
6 6 0.0523s 0.0087s 0.0523s comment | ||
4 4 0.0273s 0.0068s 0.0273s rating | ||
1 1 0.0312s 0.0312s 0.0312s book_with_categories | ||
``` | ||
|
||
## Финишный прогон тестов, В БЮДЖЕТ УЛОЖИЛСЯ: | ||
|
||
```bash | ||
Finished in 37.27 seconds (files took 2.38 seconds to load) | ||
172 examples, 0 failures | ||
Coverage report generated for (1/3), (2/3), (3/3), RSpec to /home/il53n/Desktop/ekt_library/coverage. 1594 / 1614 LOC (98.76%) covered. | ||
``` | ||
## График изменения времени прогона тестов в `Chronograf` по мере оптимизации | ||
![](data/4.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
йеее!
В такой задаче как оптимизация тестов конечно трудно понять какой "бюджет" должен быть.
Круто, что вы решили сделать в 3 раза быстрее и получилось.
Можно ещё исходить из того, что зафиксировали текущее состоянии, "подпёрли его снизу" и решили, что вот наш бюджет, по крайней мере из него выходить не будем.
А в случае успешной оптимизации передвигать и подпорку.