Skip to content

Instantly share code, notes, and snippets.

def instances(&block)
GC.enable_stats
GC.clear_stats
block.call
warmup_objs = GC.num_allocations
warmup_bytes = GC.allocated_size
GC.clear_stats
block.call
puts "=" * 50
puts "ActiveRecord::IdentityMap.enabled: #{ActiveRecord::IdentityMap.enabled}"
def instances(&block)
GC.enable_stats
GC.clear_stats
block.call
warmup_objs = GC.num_allocations
warmup_bytes = GC.allocated_size
GC.clear_stats
block.call
puts "=" * 50
puts "ActiveRecord::IdentityMap.enabled: #{ActiveRecord::IdentityMap.enabled}"
# instances method
def instances(&block)
GC.enable_stats
GC.clear_stats
block.call
warmup_objs = GC.num_allocations
warmup_bytes = GC.allocated_size
GC.clear_stats
block.call
puts "Objects:"
require 'rubygems'
require 'barby'
require 'barby/outputter/cairo_outputter'
require 'rbench'
dimensions = {:height => 70, :margin => 10}
barcode = Barby::Code128C.new('081300010000102771000000000000500000000084')
TIMES = 1000
def convert_to_png(src, out)
system("gs -sDEVICE=ppmraw -r144x144 -sOutputFile=- -sNOPAUSE \
-q #{src} -c showpage -c quit | pnmcrop | pnmmargin -white 10 | pnmtopng > #{out} 2> /dev/null")
end
def convert_to_png(src, out)
system("gs -sDEVICE=ppmraw -r144x144 -sOutputFile=- -sNOPAUSE \
-q #{src} -c showpage -c quit | pnmcrop | pnmmargin -white 10 | pnmtopng > #{out} 2> /dev/null")
end
rails/master
| AR |
------------------------------------------------------------------
Model#id x100000 | 0.967 |
Model.new (instantiation) x10000 | 0.324 |
Model.new (setting attributes) x10000 | 0.892 |
Model.first x10000 | 4.504 |
Model.all limit(100) x1000 | 11.838 |
Model.all limit(100) with relationship x1000 | 27.571 |
def debug
p "=" * 100
yield
p "=" * 100
end
- options.assert_valid_keys(VALID_FIND_OPTIONS)
+ finders.assert_valid_keys(VALID_FIND_OPTIONS)
+ finders = options.dup
+ finders.delete_if { |key, value| value.nil? }
- [:joins, :select, :group, :having, :limit, :offset, :from, :lock].each do |finder|
- if value = options[finder]
- relation = relation.send(finder, value)
- end
- end
set go-=T
set bg=dark
if &background == "dark"
hi normal guibg=black
set transp=8
endif
set wildmenu
set lines=120
set columns=130