Do assistants help faster than partial ones? How about the structure of the strings?

I have a worksheet style style in a Rails application that takes too long to load. (In dev mode, and yes, I know that there is no caching. "Completed in 57893ms (View: 54975, DB: 855)." The worksheet is rendered using helper methods because I could not withstand infinite small partial parts for different types of lines in a worksheet. Now I'm wondering if partial operations can be faster?

I profiled the page loading and identified several cases where object caching will be shaved off for a few seconds, but the profile output suggests that a large fragment of the time is spent simply looping through the composite objects of the Worksheet model and adding a line of output from the assistant. Here is an example of what I am saying:

def header_row(wksht)
  content_tag(:thead, :class => "ioe") do
    content_tag(:tr) do
      html_row = []
      for i in (0...wksht.class::NUM_COLS) do
        html_row << content_tag(:th, h(wksht.column_headings[i].upcase),
                                :class => wksht.column_classes[i])
      end
      html_row.join("\n")
    end
  end
end

OTOH partials , Ruby , , , ? , . - stringstream ( Ruby?), content_tag "" ... , - , .

( ), .:)

:

http://www.viget.com/extend/helpers-vs-partials-a-performance-question/ ()
http://www.breakingpointsystems.com/community/blog/ruby-string-processing-overhead/
http://blog.purepistos.net/index.php/2008/07/14/benchmarking-ruby-string-interpolation-concatenation-and-appending/

@tadman: ( ), , " " , Ruby, Javascript. (DRY unit testable.) Javascript / ( ) . , .

; , AR. , ( 1,7 dev, ).

, , , JS . .

+3
2

http://www.infoq.com/articles/Rails-Performance ( " Rails" ). :

def estimated_costs
  @estimated_costs ||=
    begin
      # tedious vector math
    end
end

, , , , , 90% . , , , , , :)

, , Ruby Arrays NArray (http://narray.rubyforge.org/), , , .

, . " " , , . , 1,25 .

, , , , , " " HTML, @tadman. . .

!

+6

Ruby , . , .

, , , , , . , .

- .

, - , . Memcached HTML- . 10 000 HTML , Rails.cache.

, , , , , , , , . , JavaScript, , JSON , HTML- .

+4

Source: https://habr.com/ru/post/1758438/


All Articles