Optimize task (V. Yashin)#148
Open
vladislav-yashin wants to merge 2 commits intohardcode-dev:masterfrom
Open
Conversation
added 2 commits
June 17, 2024 17:58
spajic
approved these changes
Jun 23, 2024
|
|
||
| Вот как я построил `feedback_loop`: | ||
|
|
||
| Встроил в программу progressbar для возможности визуального контроля за прогрессом выполнения |
Collaborator
There was a problem hiding this comment.
Лайк, но надо иметь в виду, что наличие прогресс-бара, особенно с большим кол-вом инкрементов может замедлять работу, поэтому именно делать замеры (бенчмаркать) лучше без него
| Зафиксировал время выполнения исходной программы на файле из 20 000 строк (около 3.3 с) | ||
| Использовал инструменты профилирования для выявления точек роста | ||
| При выявлении точки роста вносил изменения и убеждался в том, что они позитивно влияют на выбранную метрику | ||
| По мере ускорения выполнения программы увеличивал объём тестового файла |
Collaborator
There was a problem hiding this comment.
👍 да, хорошо давать программе "покрутиться" в основном цикле хотя бы несколько секунд для того чтобы собрать релевантные данные для профилировщика и избежать излишнего влияния случайных погрешностей
|
|
||
| ### Находка №2 | ||
|
|
||
| Так как время выполнения программы значительно уменьшилось на выбранном объёме данных, решил его увеличить до 100 000 строк. |
|
|
||
| users = {} | ||
|
|
||
| unique_browsers = Set[] |
| end | ||
|
|
||
| def to_h | ||
| return @to_h if defined?(@_to_h) |
Collaborator
There was a problem hiding this comment.
а где @to_h = result? вообще это излишне мне кажется тут
araslanov-e
reviewed
Jan 26, 2025
| browsers = user['sessions'].map { |s| s['browser'] } | ||
| times = user['sessions'].map { |s| s['time'].to_i } | ||
| { | ||
| 'sessionsCount' => user['sessions'].count, |
There was a problem hiding this comment.
Если не ошибаюсь, тут будет ошибка, если в файле будет информация о пользователе, но не будет информации о его сессиях
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.