-
Notifications
You must be signed in to change notification settings - Fork 25
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
Formatter is too slow #28
Comments
@vfonic I'd be very interested in what kind of code is in those 33 lines, so far my experience was very different but if there's some sort of edge case in which performance plummet I would be interested in solving them |
I don't think it's code related. Here's the code: <% content_for :form_block do %>
<div class="mb-4 text-center">
<h2 class="mb-px"><%= t('.sign_in') %></h2>
<%= t ".sign_up_html", link: link_to("sign up for an account", new_registration_path(resource_name), class: "font-semibold") if registrations_enabled? %>
</div>
<%= form_with(model: resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: true, class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :password %>
<%= f.password_field :password, autocomplete: "current-password", placeholder: true, class: "form-control" %>
</div>
<% if devise_mapping.rememberable? -%>
<div class="form-group">
<%= f.check_box :remember_me, class: "form-checkbox" %>
<%= f.label :remember_me, class: "inline-block" %>
</div>
<% end -%>
<div class="form-group">
<%= f.submit t('.sign_in'), class: "btn btn-primary btn-expanded" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<% end %>
<%= render "devise/shared/form_block" %> |
@vfonic looks like it's fast on my machine, which means it could be related to what box you're running it on to, so if you want to give me some specs I can try to reword that line in the readme so to add the proper context. For the record here are my results in VSC (on an Apple M1 laptop): While running it directly in the terminal takes from 12 to 16 microseconds. |
I also have M1. I reinstalled Homebrew (from Rosetta to ARM), reinstalled RVM, basically most of my setup. Now the formatting is done in 400-500ms. I still find that just slow enough that say it's "very fast" is misleading. Here's a screen recording of my RuboCop formatting setup speed vs erb-formatter formatting speed. Screen.Recording.2023-12-06.at.12.28.01.1080p.mov |
@vfonic Thanks for the heads up, this is a very valid point, I think the main difference is that the rubocop extension is using a server process + caching instead of individual runs. Running the formatter against 61 files took about 10ms per file on my machine:
So I think that we can try to find a way to use the same trick rubocop uses and be 10x more instant 😅 |
Yes, I've set up RuboCop to use rubocop-daemon to run the RuboCop server in the background: https://github.com/fohte/rubocop-daemon I'm a bit swamped with work at the moment, but if I find some time I'll look into optimizing the extension. Thanks! |
I installed the VS Code extension[1] after seeing this in the README here:
It takes ~1.7 seconds to format a single 33 lines of code ERB file on save.
VS Code extension output logs
Am I doing something wrong? Can this be made faster?
[1] https://marketplace.visualstudio.com/items?itemName=elia.erb-formatter
The text was updated successfully, but these errors were encountered: