-
Notifications
You must be signed in to change notification settings - Fork 181
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 #135
base: master
Are you sure you want to change the base?
homework #135
Conversation
report['usersStats'][user_key] ||= {} | ||
report['usersStats'][user_key] = report['usersStats'][user_key].merge(block.call(user)) | ||
def collect_stats_from_users(report, users, &block) | ||
progressbar = ProgressBar.create( |
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.
прогресс-бар кстати может подтормаживать, поэтому при замерах времени (бенчмаркинге) лучше его отключать
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.
добавил ProgressBar уже после всех оптимизаций, просто для пощупать и галочку проставить
|
||
report['uniqueBrowsersCount'] = uniqueBrowsers.count | ||
report[:uniqueBrowsersCount] = sessions.uniq { |session| session[:browser] }.size |
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.
Уникальные браузеры удобно в Set / SortedSet собирать
@@ -72,72 +75,40 @@ def work | |||
|
|||
report = {} | |||
|
|||
report[:totalUsers] = users.count | |||
report[:totalUsers] = users.size |
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.
для Array size и count - одно и то же
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.
def work(filename: nil, disable_gc: false) | ||
GC.disable if disable_gc | ||
users = fetch_users_and_sessions(filename) | ||
sessions = users.flat_map { |user| user[:sessions] } |
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.
Не пойму, зачем flat_map
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.
user[:sessions]
массив же, без flat_map надо было бы делать flatten
после map
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 👍
Где лучше оставлять вопросы, здесь или в teachbase? Пока оставлю тут:
Как поток понимает, что происходит IO операция, и что будет с потоком, когда IO операция завершится? За это ядро ОС отвечает? Где можно подробности работы с потоками и процессами разобрать?
Отчет в https://www.speedscope.app не открылся, ругается на формат, хотя кидаю сгенерированный json