-
Notifications
You must be signed in to change notification settings - Fork 140
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
Optimize task 2 #120
base: master
Are you sure you want to change the base?
Optimize task 2 #120
Conversation
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.
✅
Я решил исправить эту проблему, оптимизировав эту программу. | ||
|
||
## Формирование метрики | ||
Я проверила memory usage на файлах с меньшим числом строк кода, и увидела, что бюджет превышается уже на 8000. |
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.
👍
Я решила на первых этапах пользоваться результатами отчета по количеству памяти от memory-profiler, т.к. он показывает не только аллокации, но и потребляему память | ||
Кроме того, т.к. первые находки соотвествуют тем, что были в прошлых заданиях, я не буду подробно их расписывать. Исправляю по очереди, когда меняется главная точка роста. | ||
|
||
### Находки №1-5 |
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.
👍 👍 👍 👍 👍
К моменту исправления восьмой проблемы на 16000 строк в конце программы MEMORY USAGE: 46 MB и 85 MB с отключенным GC | ||
Изменения на этом этапе не значительные, поэтому исходя из находки №6 решаю переписать программу на поточный алгоритм. | ||
|
||
После переписывания программы на поточный алгоритм memory_usage в конце выполнения программы на 1000-32000 строк одинаковый 26 MB. После этого проверяю для полного файла - MEMORY USAGE в конце исполнения такой же - 26 MB. Запускаю benchmark - время выполнения на большом файле - 12,38 секунд! |
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.
топчик, особенно радует, что так любой объём данных можно перемолоть
|
||
После переписывания программы на поточный алгоритм memory_usage в конце выполнения программы на 1000-32000 строк одинаковый 26 MB. После этого проверяю для полного файла - MEMORY USAGE в конце исполнения такой же - 26 MB. Запускаю benchmark - время выполнения на большом файле - 12,38 секунд! | ||
|
||
На этом этапе добавила треды, чтобы проверить, что memory usage не превышает заданного параметра на всем протяжении работы программы, а не только в конце. Максимальный объем памяти - 42MB |
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.
👍
|
||
result_file = File.open('result.json', 'w') | ||
|
||
stream_writer = Oj::StreamWriter.new(result_file) |
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.
да-да, так покрасивее чем json руками собирать 👍
@@ -0,0 +1,96 @@ | |||
require 'json' |
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.
# frozen_string_literal: true
бы не помешало
No description provided.