Advertisement
Guest User

Untitled

a guest
Nov 28th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. items = 1000.times.map { |i| {id: "quick? or slow?"}}
  2.  
  3. time = Time.now
  4. json.array! items do |item|
  5. json.partial! 'partial_perf/item', item: item
  6. end
  7. puts "time of iteration a partial: #{Time.now - time}"
  8.  
  9. time = Time.now
  10. json.array! items do |item|
  11. json.id item[:id]
  12. end
  13. puts "time of iteration an array: #{Time.now - time}"
  14.  
  15.  
  16. # time = Time.now.getutc
  17. # json.partial! 'partial_perf/item', collection: items, as: :item
  18. # puts "#{Time.now - time}"
  19.  
  20.  
  21. time = Time.now.getutc
  22. json.array! items do |item|
  23. json.cache! item do
  24. json.partial! 'partial_perf/item', item: item
  25. end
  26. end
  27. puts "time of iteration a cache partial: #{Time.now - time}"
  28.  
  29.  
  30. # time = Time.now.getutc
  31. # json.cache! items do
  32. # json.partial! 'partial_perf/item', collection: items, as: :item
  33. # end
  34. # puts "#{Time.now - time}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement