-
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
homework 2 #121
base: master
Are you sure you want to change the base?
homework 2 #121
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.
✅ nice work!
require 'benchmark' | ||
|
||
puts "SIZE #{ENV['SIZE']}" | ||
puts Benchmark.realtime { work("data/data#{ENV['SIZE']}.txt", disable_gc: ENV['GB'] || false) } |
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.
почему GB-то? 😄
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.
Опечатка которая преследовала до конца. :)
Для того, чтобы понимать, дают ли мои изменения положительный эффект на быстродействие программы я придумал использовать такую метрику: программа должна потреблять меньше 70Мб памяти при обработке файла data_large.txt | ||
|
||
Предварительно на | ||
- 10_000 строк из файла используется MEMORY USAGE: без GB 360 MB(c GB 82 MB) скороть работы 1.765 сек |
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.
GC == Garbage Collector
6.934339999977965 | ||
``` | ||
|
||
замеры через memory_profiler.rb |
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.
через profiler не надо делать замеры. замеры отдельно, профайлинг отдельно
0.3854719999944791 | ||
``` | ||
|
||
но потребляемая память в конкретном месте уменьшилась до |
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.
тут лучше быть более точным, что такое потребляемая память не совсем понятно; тут конкретно речь идёт про объём аллоцированной памяти
8.14 MB rails-optimization-task2/work.rb:28 | ||
``` | ||
- заменяб сохранение после split не в массив, а в переннеыю | ||
`type, user_id, second, third, fourth, fifth = line.split(',')`, так же `parse_user` и `parse_session` убрал split и пользуюсь уже готовыми переменными. |
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.
да-да, отлично, простое решение, которое убирает огромное количество аллокаций в цикле
``` | ||
|
||
### Ваша находка №4 | ||
- Подняд нагрузку до 200_000 |
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.
это не нагрузка, а скорее объём файла просто (сорри за духоту)
|
||
it 'performs success' do | ||
work(data_file_path) | ||
expect((`ps -o rss= -p #{Process.pid}`.to_i / 1024)).to be < 70 |
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.
👍
No description provided.