Open
Conversation
spajic
approved these changes
Mar 9, 2019
Owner
spajic
left a comment
There was a problem hiding this comment.
Аппрув + несколько комментов + обсудим на лекции №2
|
|
||
| ## Формирование метрики | ||
| Для того, чтобы понимать, дают ли мои изменения положительный эффект на быстродействие программы я придумал использовать такую метрику: *тут ваша метрика* | ||
| Попытался запустить исходный код и тот самый `data_large.txt`, но спустя примерно 20 минут ожиданий я забросил это дело. Выбрал выборку поменьше (весом ~ 700кб), общее время выполнения кода стало ~ 19 сек. Путем нехитрых вычислений прикинем, что общее время для анализа файла весом в 135 мб составит около 61 минуты. |
Owner
There was a problem hiding this comment.
Насчёт 61 минуты не совсем обоснованный вывод
|
|
||
| Были удалены повторяющиеся `collect_stats_from_users`, которые постоянно гоняли `user_objects`, когда можно было по уже готовому массиву `users` пройти один раз, записав все нужные значения для отчета, что и было сделано. | ||
|
|
||
| После всех этих манипуляций итоговое время выполнение кода стало ~ 3.15 секунды. |
Owner
There was a problem hiding this comment.
Сгруппировали многовато оптимизаций вместе, в итоге непонятно какая оптимизация какой дала эффект
| После всех этих манипуляций итоговое время выполнение кода стало ~ 3.15 секунды. | ||
|
|
||
| ### Оптимизация №3 | ||
| Далее самой прожорливой строчкой была `task-1.rb:140`, а именно метод `Date#parse`, на который было затрачено 17мб памяти. Путем гугления `Date#parse ruby benchmark` выяснил, что есть быстрее метод - `Date#strptime`. Замена на него снизило выделение памяти до 6.1мб, а общее время выполнения кода стало ~ 2.45 секунд. |
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.
Finish in 85.84 sec
Mode: object(1)
Samples: 74945994 (0.00% miss rate)
GC: 0 (0.00%)
TOTAL (pct) SAMPLES (pct) FRAME
74945993 (100.0%) 45687533 (61.0%) Object#report
24758460 (33.0%) 24758460 (33.0%) Object#parse_session
4500000 (6.0%) 4500000 (6.0%) Object#parse_user