Hi,

As Bryan already mentioned about it, <a> and <view> for active record
objects are slow.  Eliminating calls for those tags (and fields=""
attribute which calls <view> internally) may be worth it.

See following results.  You'll see dryml itself is already not fast
(the first entry, 500 * "string" takes 250..300ms including GC), as
well as <a> and <view> are much slower.

    <!-- app/views/front/index.dryml -->
    <section class="content-body">
      <!-- C2Q 9550 2.83GHz, Linux 3.2.0-2-686-pae (Debian sid), ruby 
1.9.2p180, hobo 1.3.0, rails 3.0.10
           guest (GC enabled)
               / logged-in user (GC enabled)
                      / logged-in user (GC enabled, custom <view for="User">)
                             / logged-in user (GC disabled) -->
      <br/>
      <!-- 316 /  311 /  312 /  248 ms --><how-slow num="500">string</how-slow>
      <!-- 214 /  209 /  214 /  182 ms --><how-slow num="400">string</how-slow>
      <!-- 159 /  154 /  155 /  126 ms --><how-slow num="300">string</how-slow>
      <!--  83 /   80 /   82 /   82 ms --><how-slow num="200">string</how-slow>
      <!--  50 /   49 /   50 /   52 ms --><how-slow num="100">string</how-slow>
      <!-- 313 /  310 /  316 /  250 ms --><how-slow><%= can_view?(current_user) 
%></how-slow>
      <!-- 709 /  700 /  702 /  572 ms --><how-slow><view 
with="&%(string)"/></how-slow>
      <br/>
      <!-- 309 /  384 /  382 /  320 ms --><how-slow><%= current_user.to_s 
%></how-slow>
      <!-- 708 /  765 /  769 /  639 ms --><how-slow><view 
with="&current_user.to_s"/></how-slow>
      <br/>
      <!-- 343 /  494 /  498 /  405 ms --><how-slow><do 
with="&current_user"><%= this.login %></do></how-slow>
      <!-- 738 /  964 /  967 /  794 ms --><how-slow><do 
with="&current_user"><view with="&this.login"/></do></how-slow>
      <!-- 735 / 1078 / 1054 /  904 ms --><how-slow><do 
with="&current_user"><view:login/></do></how-slow>
      <br/>
      <!-- 721 /  704 /  708 /  581 ms --><how-slow><a 
href="&user_path(1)">string</a></how-slow>
      <!-- 317 /  789 /  794 /  673 ms --><how-slow><% raise 
Hobo::PermissionDeniedError unless can_view?(current_user) %><% if 
current_user.signed_up? %><a href="&user_path(current_user.id)"><%= 
current_user.to_s %></a><% else %><%= current_user.to_s %><% end %></how-slow>
      <!-- 343 /  824 /  825 /  696 ms --><how-slow><do with="&current_user"><% 
raise Hobo::PermissionDeniedError unless can_view? %><% if this.signed_up? %><a 
href="&user_path(this.id)"><%= this.to_s %></a><% else %><%= this.to_s %><% end 
%></do></how-slow>
      <!-- 410 / 2310 / 1329 / 1905 ms --><how-slow><view 
with="&current_user"/></how-slow>
      <!-- 425 / 1633 / 1635 / 1384 ms --><how-slow><a 
with="&current_user"/></how-slow>
    </section>

    <!-- app/views/taglibs/application.dryml -->
    <def tag="how-slow" attrs="num">
      <% disable_gc = false %>
      <% num ||= 500 %>
      <% GC.start %>
      <% GC.disable if disable_gc %>
      <% t0 = Time.now %>
      <div style="display: none;">
        <repeat with="&(0..(num.to_i))">
          <do param="default"/>
        </repeat>
      </div>
      <% GC.enable if disable_gc %>
      <% GC.start %>
      <% t1 = Time.now %>
      <br/>
      <%= ((t1 - t0) * 1000).to_i %>
    </def>

    <!--
    <def tag="view" for="User">
      <% raise Hobo::PermissionDeniedError, "view of non-viewable user #{this}" 
unless can_view? %>
      <% if this.signed_up? %>
        <a href="&user_path(this.id)"><%= this.to_s %></a><%# 
user_path(user.id) is much faster than user_path(user) %>
      <% else %>
        <%= this.to_s %>
      <% end %>
    </def>
    -->

-----
Tomoaki Hayasaka <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to