Ryuta Kamizono
c81af6ae72
Enable Layout/EmptyLinesAroundAccessModifier
cop
...
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776 ,
https://github.com/rails/rails/pull/34832#discussion_r244847195 ).
Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059 ).
That cop and enforced style will reduce the our code review cost.
2019-06-13 12:00:45 +09:00
Eileen Uchitelle
e8c1be4ae7
Add allocations to template renderer subscription
...
This PR adds the allocations to the instrumentation for template and
partial rendering.
Before:
```
Rendering posts/new.html.erb within layouts/application
Rendered posts/_form.html.erb (9.7ms)
Rendered posts/new.html.erb within layouts/application (10.9ms)
Completed 200 OK in 902ms (Views: 890.8ms | ActiveRecord: 0.8ms)
```
After:
```
Rendering posts/new.html.erb within layouts/application
Rendered posts/_form.html.erb (Duration: 7.1ms | Allocations: 6004)
Rendered posts/new.html.erb within layouts/application (Duration: 8.3ms | Allocations: 6654)
Completed 200 OK in 858ms (Views: 848.4ms | ActiveRecord: 0.4ms | Allocations: 1539564)
```
2018-10-10 08:07:12 -04:00
yuuji.yaginuma
1b86d90136
Enable Performance/UnfreezeString
cop
...
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.
```ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org "
gem "benchmark-ips"
end
Benchmark.ips do |x|
x.report('+@') { +"" }
x.report('dup') { "".dup }
x.compare!
end
```
```
$ ruby -v benchmark.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Warming up --------------------------------------
+@ 282.289k i/100ms
dup 187.638k i/100ms
Calculating -------------------------------------
+@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s
dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s
Comparison:
+@: 6775299.3 i/s
dup: 3320400.7 i/s - 2.04x slower
```
2018-09-23 08:56:55 +09:00
Koichi ITO
b427c461ef
[Action View] rubocop -a --only Layout/EmptyLineAfterMagicComment
2017-07-11 13:12:32 +09:00
Kir Shatrov
b3f3d49fd6
Prepare AP and AR to be frozen string friendly
2017-07-06 21:30:43 +03:00
Matthew Draper
87b3e226d6
Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
...
This reverts commit 3420a14590
, reversing
changes made to afb66a5a59
.
2017-07-02 02:15:17 +09:30
Matthew Draper
3420a14590
Merge pull request #29540 from kirs/rubocop-frozen-string
...
Enforce frozen string in Rubocop
2017-07-02 01:11:50 +09:30
Kir Shatrov
cfade1ec7e
Enforce frozen string in Rubocop
2017-07-01 02:11:03 +03:00
Pat Allan
3d453b409d
Make ActionView frozen string literal friendly.
...
Plus a couple of related ActionPack patches.
2017-06-20 22:20:04 +10:00
Kasper Timm Hansen
8240636bed
Merge pull request https://github.com/rails/rails/pull/28637 from st0012/fix-partial-cache-logging
2017-06-08 21:42:46 +02:00
Akira Matsuda
7f998540af
Privatize unneededly protected methods in Action View
2016-12-24 22:16:47 +09:00
Stan Lo
ab2af4dfcb
Modify LogSubscriber for single partial's cache message.
...
Implement naive partial caching mechanism.
Add test for LogSubscriber
Use ActionView::Base#log_payload to store log_subscriber's payload, so we can pass cache result into it.
Fixed tests
Remove useless settings
Check if #log_payload exists before calling it. Because other classes also includes CacheHelper but don't have is attribute
Use @log_payload_for_partial_reder instead of #log_payload to carry ActionView's payload.
Update test's hash syntax
Add configuration to enable/disable fragment caching logging
Remove unless test and add new test to ensure cache info won't effect next rendering's log
Move :enable_fragment_cache_logging config from ActionView to ActionPack
Apply new config to tests
Update actionview's changelog
Update configuration guide
Improve actionview's changelog
Refactor PartialRenderer#render and log tests
Mute subscriber's log instead of disabling instrumentation.
Fix typo, remove useless comment and use new hash syntax
Improve actionpack's log_subscriber test
Fix rebase mistake
Apply new config to all caching intstrument actions
2016-08-08 00:24:39 +08:00
Xavier Noria
66a7cfa910
applies new string literal convention in actionview/lib
...
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:48:35 +02:00
Prem Sichanugrist
b84ca28a21
Update to use Subscriber#start instead
...
We don't need to instrument another event as
`ActiveSupport::LogSubscriber` already tracks when the instrumentation
starts.
Close #23717
2016-02-26 13:23:59 -05:00
Vipul A M
c8915ec335
Added log "Rendering ...", when starting to render a template, to log that we have started to render something, at the very beginning.
...
This helps to easily identify queries from controller vs views
Fixes #23710
2016-02-26 12:08:51 -05:00
Kasper Timm Hansen
b4700de1ce
Instrument cached collection renders.
...
Augments the collection caching with some instrumentation that's logged.
For collections that have been cached like:
```ruby
<%= render partial: 'notifications/notification', collection: @notifications, cached: true %>
```
We'll output a line showing how many cache hits we had when rendering it:
```
Rendered collection of notifications/_notification.html.erb [0 / 100 cache hits] (3396.5ms)
```
2016-02-20 18:34:41 +01:00
Guo Xiang Tan
ee35b79d4c
Prefer to pass block when logging.
...
The Logger by default includes a guard which checks for the
logging level. By removing the custom logging guards, we can decouple
the logging guard from the logging action to be done.
This also follows the good practice listed on http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance .
2014-07-18 15:04:43 +08:00
Rafael Mendonça França
87d0bde03f
Drop one more string allocation
2013-11-09 18:28:32 -02:00
Arun Agrawal
daf226abc8
sub! can return nil
...
Revert "drop one more string allocation"
This reverts commit 4d15661d6c
.
2013-11-07 20:08:32 +01:00
Aaron Patterson
4d15661d6c
drop one more string allocation
2013-11-06 14:46:14 -08:00
Aaron Patterson
68b7e381f1
drop string allocations in the log subscriber
2013-11-06 14:37:30 -08:00
Łukasz Strzałkowski
7c8817aeef
Add missing require
2013-08-25 11:39:12 +02:00
Piotr Sarnacki
0d6e8edc2a
Move actionpack/lib/action_view* into actionview/lib
2013-06-20 17:23:15 +02:00