Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- items = 1000.times.map { |i| {id: "quick? or slow?"}}
- time = Time.now
- json.array! items do |item|
- json.partial! 'partial_perf/item', item: item
- end
- puts "time of iteration a partial: #{Time.now - time}"
- time = Time.now
- json.array! items do |item|
- json.id item[:id]
- end
- puts "time of iteration an array: #{Time.now - time}"
- # time = Time.now.getutc
- # json.partial! 'partial_perf/item', collection: items, as: :item
- # puts "#{Time.now - time}"
- time = Time.now.getutc
- json.array! items do |item|
- json.cache! item do
- json.partial! 'partial_perf/item', item: item
- end
- end
- puts "time of iteration a cache partial: #{Time.now - time}"
- # time = Time.now.getutc
- # json.cache! items do
- # json.partial! 'partial_perf/item', collection: items, as: :item
- # end
- # puts "#{Time.now - time}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement