Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

homework 2 #121

wants to merge 8 commits into from

Conversation

God1-ike
Copy link

@God1-ike God1-ike commented Feb 8, 2025

No description provided.

Copy link
Collaborator

@spajic spajic left a 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) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему GB-то? 😄

Copy link
Author

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 сек
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

через profiler не надо делать замеры. замеры отдельно, профайлинг отдельно

0.3854719999944791
```

но потребляемая память в конкретном месте уменьшилась до
Copy link
Collaborator

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 и пользуюсь уже готовыми переменными.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да-да, отлично, простое решение, которое убирает огромное количество аллокаций в цикле

```

### Ваша находка №4
- Подняд нагрузку до 200_000
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants