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 #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

homework #105

wants to merge 1 commit into from

Conversation

ksilex
Copy link

@ksilex ksilex commented Nov 6, 2023

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, респект за потоковую обработку и понимание что индексы тут не помогут, а в чём-то могут и помешать

# frozen_string_literal: true

require 'oj'
class ReloadJson
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • за отдельный класс

</ul>
<%= render "delimiter" %>
<% end %>
<%= render partial: 'trip', collection: @trips, as: :trip %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Есть ещё забавная возможность задать разделитель параметром: https://guides.rubyonrails.org/layouts_and_rendering.html#spacer-templates

После оптимизации обработак medium файла - ~ 1 сек, память - 87 MB

Обработка large.json - ~ 7.6 сек, память - 87MB

Copy link
Collaborator

Choose a reason for hiding this comment

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

💪 💪 💪 💪 respect

# Б. Отображение расписаний
Начну с rack-mini-profiler

Без профилировщика страница с 1004 трипов загружается за 3.4 секунды, с профилировщиком - 19 сек
Copy link
Collaborator

Choose a reason for hiding this comment

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

надо всегда разделять профилирование отдельно - замеры отдельно

![Alt text](<images/Screenshot from 2023-11-06 18-32-17.png>)
Общее время запроса в среднем 315ms

Считаю на этом можно остановиться, т.к. улучшение запросов почти не принесет пользы, а импорты могут замедлиться из-за добавления индексов
Copy link
Collaborator

Choose a reason for hiding this comment

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

В принципе да

Тут забавно, что pg_hero может подсказать какие индексы надо добавить.

С точки зрения рендеринга страницы это ничего не даст. Но если бы мы смотрели с точки зрения нагрузки на БД, это была бы оптимизация №1

Copy link
Author

Choose a reason for hiding this comment

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

Я все равно в pg_hero заглянул и проверил будет ли ругаться - вся панель была зеленая, 0 problems, видимо, suggest'ы по индексам при привышении какого-то лимита по времени только появляются

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