Skip to content

Instantly share code, notes, and snippets.

map <D-1> :tabn 1<CR>
map <D-2> :tabn 2<CR>
map <D-3> :tabn 3<CR>
map <D-4> :tabn 4<CR>
map <D-5> :tabn 5<CR>
map <D-6> :tabn 6<CR>
map <D-7> :tabn 7<CR>
map <D-8> :tabn 8<CR>
map <D-9> :tabn 9<CR>
~/Workspace/github/miloops/rails/activerecord(master) $ ruby examples/performance.rb
Thread ID: 2148368700
Total: 3.848270
%self total self wait child calls name
15.08 0.89 0.58 0.00 0.31 20003 Array#each (ruby_runtime:0}
7.03 3.77 0.27 0.00 3.50 10000 ActiveRecord::Base#initialize (./examples/../lib/active_record/base.rb:1430}
4.83 0.92 0.19 0.00 0.80 20000 <Class::ActiveRecord::Base>#_initialize_superclass_callbacks (/Users/miloops/Workspace/github/miloops/rails/activesupport/lib/active_support/callbacks.rb:568}
4.82 1.56 0.19 0.00 1.37 10000 ActiveRecord::Base#_run_initialize_callbacks (/Users/miloops/Workspace/github/miloops/rails/activesupport/lib/active_support/callbacks.rb:392}
3.89 0.45 0.15 0.00 0.30 10000 <Class::ActiveRecord::Base>#scoped_methods (./examples/../lib/active_record/base.rb:1200}
diff --git a/lib/arel/engines/sql/relations/compiler.rb b/lib/arel/engines/sql/relations/compiler.rb
index 374967b..05a8f16 100644
--- a/lib/arel/engines/sql/relations/compiler.rb
+++ b/lib/arel/engines/sql/relations/compiler.rb
@@ -8,17 +8,28 @@ module Arel
end
def select_sql
- query = build_query \
- "SELECT #{select_clauses.join(', ')}",
# using mysql gem
>> puts Benchmark.measure{10.times{ActiveRecord::Base.connection.execute("select * from registrations")}}
1.860000 1.900000 3.760000 ( 25.765718)
# using mysql2 gem
>> puts Benchmark.measure{10.times{ActiveRecord::Base.connection.execute("select * from registrations")}}
1.820000 1.850000 3.670000 ( 18.838711)
# looks really cool, but... we never do that kind of queries, let's get realistic
abstract (1.0.0)
actionmailer (3.0.0.rc)
actionpack (3.0.0.rc)
activemodel (3.0.0.rc)
activerecord (3.0.0.rc)
activeresource (3.0.0.rc)
activesupport (3.0.0.rc)
arel (0.4.0)
autotest (4.3.2)
autotest-fsevent (0.2.2)
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
- 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
def debug
p "=" * 100
yield
p "=" * 100
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 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