user system total real with collection 19.210000 0.030000 19.240000 ( 19.278860) with partial 55.260000 3.050000 58.310000 ( 58.442582) with helper 16.640000 0.020000 16.660000 ( 16.663933)
here is the code
- n = 51_000
- some_array = n.times.collect{'hello'}
- Benchmark.bm do |x|
- x.report("with collection") do
= render partial: 'name', collection: some_array, locals: {name: 'hello'}
- x.report("with partial") do
- n.times.each do
= render 'name', name: "hello"
- x.report("with helper") do
- n.times.each do
= prunt "hello"
helper:
def prunt name
(
content_tag(:h1, name) +
link_to('http://www.dir.bg')
).html_safe
end
more https://github.com/gudata/rendering