Open
Conversation
spajic
approved these changes
Feb 16, 2025
| require 'benchmark' | ||
|
|
||
| puts "SIZE #{ENV['SIZE']}" | ||
| puts Benchmark.realtime { work("data/data#{ENV['SIZE']}.txt", disable_gc: ENV['GB'] || false) } |
Author
There was a problem hiding this comment.
Опечатка которая преследовала до конца. :)
| Для того, чтобы понимать, дают ли мои изменения положительный эффект на быстродействие программы я придумал использовать такую метрику: программа должна потреблять меньше 70Мб памяти при обработке файла data_large.txt | ||
|
|
||
| Предварительно на | ||
| - 10_000 строк из файла используется MEMORY USAGE: без GB 360 MB(c GB 82 MB) скороть работы 1.765 сек |
| 6.934339999977965 | ||
| ``` | ||
|
|
||
| замеры через memory_profiler.rb |
Collaborator
There was a problem hiding this comment.
через profiler не надо делать замеры. замеры отдельно, профайлинг отдельно
| 0.3854719999944791 | ||
| ``` | ||
|
|
||
| но потребляемая память в конкретном месте уменьшилась до |
Collaborator
There was a problem hiding this comment.
тут лучше быть более точным, что такое потребляемая память не совсем понятно; тут конкретно речь идёт про объём аллоцированной памяти
| 8.14 MB rails-optimization-task2/work.rb:28 | ||
| ``` | ||
| - заменяб сохранение после split не в массив, а в переннеыю | ||
| `type, user_id, second, third, fourth, fifth = line.split(',')`, так же `parse_user` и `parse_session` убрал split и пользуюсь уже готовыми переменными. |
Collaborator
There was a problem hiding this comment.
да-да, отлично, простое решение, которое убирает огромное количество аллокаций в цикле
| ``` | ||
|
|
||
| ### Ваша находка №4 | ||
| - Подняд нагрузку до 200_000 |
Collaborator
There was a problem hiding this comment.
это не нагрузка, а скорее объём файла просто (сорри за духоту)
|
|
||
| it 'performs success' do | ||
| work(data_file_path) | ||
| expect((`ps -o rss= -p #{Process.pid}`.to_i / 1024)).to be < 70 |
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.