Top 10 Ruby on Rails performance tips
1. 最佳化你的ruby code
1.1 如果內建就有, 就別自己幹
1.2 能用regular expression 就別用loop
1.3 用 Libxml 別用 REXML 如果妳要parse xml
1.4 define_method, yield 動態生function 很方便, 可是也要好好評量一下
1.5 儘量別用loop,
1.6 if/unless 可以儘量簡單或別用, 別忘了 ||=
1.7 Hash 很貴, 如果妳有需要常用的話, 把他存在local variable裡
2. Cache is good
2.1 model : cached_model gem
2.2 page : extended_fragment_cache
3. finders are great but be careful
3.1 select , 只拿妳需要的
3.2 別忘了 include
3.3 MyModel.find_by_* 會痛 別用
3.4 想快 就用 find_by_sql
4. Group operations in a transaction:
!! 用transaction 包起來這樣比較快, 如果妳有需要不停的insert or update record 的話
5. Control your controllers
5.1 filter 很貴, 別用太多, instance variable 也是
6. Use HTML for your views:
6.1 helper 別用太爽
7. Logging
7.1 logging 也很貴, 別啥都記
8. Profile 是好物
2009年1月2日 星期五
Top 10 Ruby on Rails performance tips
Top 10 Ruby on Rails performance tips
1. 最佳化你的ruby code
1.1 如果內建就有, 就別自己幹
1.2 能用regular expression 就別用loop
1.3 用 Libxml 別用 REXML 如果妳要parse xml
1.4 define_method, yield 動態生function 很方便, 可是也要好好評量一下
1.5 儘量別用loop,
1.6 if/unless 可以儘量簡單或別用, 別忘了 ||=
1.7 Hash 很貴, 如果妳有需要常用的話, 把他存在local variable裡
2. Cache is good
2.1 model : cached_model gem
2.2 page : extended_fragment_cache
3. finders are great but be careful
3.1 select , 只拿妳需要的
3.2 別忘了 include
3.3 MyModel.find_by_* 會痛 別用
3.4 想快 就用 find_by_sql
4. Group operations in a transaction:
!! 用transaction 包起來這樣比較快, 如果妳有需要不停的insert or update record 的話
5. Control your controllers
5.1 filter 很貴, 別用太多, instance variable 也是
6. Use HTML for your views:
6.1 helper 別用太爽
7. Logging
7.1 logging 也很貴, 別啥都記
8. Profile 是好物
1. 最佳化你的ruby code
1.1 如果內建就有, 就別自己幹
1.2 能用regular expression 就別用loop
1.3 用 Libxml 別用 REXML 如果妳要parse xml
1.4 define_method, yield 動態生function 很方便, 可是也要好好評量一下
1.5 儘量別用loop,
1.6 if/unless 可以儘量簡單或別用, 別忘了 ||=
1.7 Hash 很貴, 如果妳有需要常用的話, 把他存在local variable裡
2. Cache is good
2.1 model : cached_model gem
2.2 page : extended_fragment_cache
3. finders are great but be careful
3.1 select , 只拿妳需要的
3.2 別忘了 include
3.3 MyModel.find_by_* 會痛 別用
3.4 想快 就用 find_by_sql
4. Group operations in a transaction:
!! 用transaction 包起來這樣比較快, 如果妳有需要不停的insert or update record 的話
5. Control your controllers
5.1 filter 很貴, 別用太多, instance variable 也是
6. Use HTML for your views:
6.1 helper 別用太爽
7. Logging
7.1 logging 也很貴, 別啥都記
8. Profile 是好物
標籤:
performance
2008年11月2日 星期日
訂閱:
文章 (Atom)