diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-18 15:57:11 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-18 15:57:11 -0700 |
commit | d993cb362969caa2cb3b3f2f86ddf653d34dfb1b (patch) | |
tree | d0323e630d3308b7852441d4e80b9a944054f41b /activesupport | |
parent | 4d9475bef91d1df675750aabc13de23c6eff9e92 (diff) | |
download | rails-d993cb362969caa2cb3b3f2f86ddf653d34dfb1b.tar.gz rails-d993cb362969caa2cb3b3f2f86ddf653d34dfb1b.tar.bz2 rails-d993cb362969caa2cb3b3f2f86ddf653d34dfb1b.zip |
drop array allocations when building paths
```ruby
require 'action_pack'
require 'action_dispatch'
require 'benchmark/ips'
route_set = ActionDispatch::Routing::RouteSet.new
routes = ActionDispatch::Routing::Mapper.new route_set
ObjectSpace::AllocationTracer.setup(%i{path line type})
result = ObjectSpace::AllocationTracer.trace do
500.times do
routes.resources :foo
end
end
sorted = ObjectSpace::AllocationTracer.allocated_count_table.sort_by(&:last)
sorted.each do |k,v|
next if v == 0
p k => v
end
__END__
Before:
{:T_SYMBOL=>11}
{:T_REGEXP=>17}
{:T_STRUCT=>6500}
{:T_MATCH=>12004}
{:T_OBJECT=>99009}
{:T_DATA=>100088}
{:T_HASH=>122015}
{:T_STRING=>159637}
{:T_IMEMO=>363134}
{:T_ARRAY=>433056}
After:
{:T_SYMBOL=>11}
{:T_REGEXP=>17}
{:T_STRUCT=>6500}
{:T_MATCH=>12004}
{:T_OBJECT=>91009}
{:T_DATA=>100088}
{:T_HASH=>114013}
{:T_STRING=>159637}
{:T_ARRAY=>321056}
{:T_IMEMO=>351133}
```
Diffstat (limited to 'activesupport')
0 files changed, 0 insertions, 0 deletions