rails 2.2.3 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails might be problematic. Click here for more details.

Files changed (229) hide show
  1. data/CHANGELOG +272 -191
  2. data/MIT-LICENSE +1 -1
  3. data/README +6 -19
  4. data/Rakefile +24 -71
  5. data/bin/rails +1 -0
  6. data/builtin/rails_info/rails/info.rb +12 -8
  7. data/configs/databases/mysql.yml +3 -0
  8. data/configs/initializers/backtrace_silencers.rb +7 -0
  9. data/configs/initializers/new_rails_defaults.rb +2 -0
  10. data/configs/initializers/session_store.rb +15 -0
  11. data/dispatches/config.ru +7 -0
  12. data/doc/README_FOR_APP +2 -5
  13. data/environments/boot.rb +1 -0
  14. data/environments/environment.rb +14 -48
  15. data/environments/production.rb +11 -7
  16. data/environments/test.rb +6 -0
  17. data/helpers/application_controller.rb +10 -0
  18. data/helpers/test_helper.rb +1 -1
  19. data/html/500.html +0 -3
  20. data/html/index.html +1 -0
  21. data/lib/commands/about.rb +1 -1
  22. data/lib/commands/dbconsole.rb +18 -2
  23. data/lib/commands/plugin.rb +4 -3
  24. data/lib/commands/runner.rb +13 -7
  25. data/lib/commands/server.rb +98 -33
  26. data/lib/console_app.rb +4 -4
  27. data/lib/console_with_helpers.rb +2 -23
  28. data/lib/dispatcher.rb +1 -1
  29. data/lib/fcgi_handler.rb +12 -10
  30. data/lib/initializer.rb +108 -41
  31. data/lib/rails/backtrace_cleaner.rb +54 -0
  32. data/lib/rails/gem_dependency.rb +124 -94
  33. data/lib/rails/plugin.rb +49 -6
  34. data/lib/rails/plugin/loader.rb +66 -27
  35. data/lib/rails/plugin/locator.rb +1 -1
  36. data/lib/rails/rack.rb +3 -1
  37. data/lib/rails/rack/debugger.rb +21 -0
  38. data/lib/rails/rack/log_tailer.rb +35 -0
  39. data/lib/rails/rack/metal.rb +51 -0
  40. data/lib/rails/rack/static.rb +15 -4
  41. data/lib/rails/version.rb +2 -2
  42. data/lib/rails_generator/base.rb +3 -0
  43. data/lib/rails_generator/commands.rb +8 -3
  44. data/lib/rails_generator/generators/applications/app/app_generator.rb +210 -136
  45. data/lib/rails_generator/generators/applications/app/scm/git.rb +16 -0
  46. data/lib/rails_generator/generators/applications/app/scm/scm.rb +8 -0
  47. data/lib/rails_generator/generators/applications/app/scm/svn.rb +7 -0
  48. data/lib/rails_generator/generators/applications/app/template_runner.rb +401 -0
  49. data/lib/rails_generator/generators/components/controller/USAGE +12 -11
  50. data/lib/rails_generator/generators/components/controller/controller_generator.rb +7 -1
  51. data/lib/rails_generator/generators/components/controller/templates/helper_test.rb +4 -0
  52. data/lib/rails_generator/generators/components/helper/USAGE +24 -0
  53. data/lib/rails_generator/generators/components/helper/helper_generator.rb +25 -0
  54. data/lib/rails_generator/generators/components/helper/templates/helper.rb +2 -0
  55. data/lib/rails_generator/generators/components/helper/templates/helper_test.rb +4 -0
  56. data/lib/rails_generator/generators/components/metal/USAGE +8 -0
  57. data/lib/rails_generator/generators/components/metal/metal_generator.rb +8 -0
  58. data/lib/rails_generator/generators/components/metal/templates/metal.rb +12 -0
  59. data/lib/rails_generator/generators/components/resource/USAGE +2 -2
  60. data/lib/rails_generator/generators/components/resource/resource_generator.rb +2 -0
  61. data/lib/rails_generator/generators/components/resource/templates/helper_test.rb +4 -0
  62. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +2 -0
  63. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +1 -1
  64. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +4 -4
  65. data/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +4 -0
  66. data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +1 -1
  67. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +2 -2
  68. data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +2 -2
  69. data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +2 -2
  70. data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +1 -1
  71. data/lib/rails_generator/secret_key_generator.rb +2 -0
  72. data/lib/tasks/databases.rake +13 -6
  73. data/lib/tasks/documentation.rake +2 -9
  74. data/lib/tasks/framework.rake +26 -1
  75. data/lib/tasks/gems.rake +33 -48
  76. data/lib/tasks/middleware.rake +7 -0
  77. data/lib/tasks/misc.rake +7 -0
  78. data/lib/tasks/statistics.rake +0 -1
  79. data/lib/tasks/testing.rake +5 -5
  80. data/lib/tasks/tmp.rake +2 -2
  81. data/lib/test_help.rb +16 -8
  82. metadata +92 -159
  83. data/bin/performance/request +0 -3
  84. data/bin/process/inspector +0 -3
  85. data/bin/process/reaper +0 -3
  86. data/bin/process/spawner +0 -3
  87. data/config.ru +0 -17
  88. data/configs/apache.conf +0 -40
  89. data/configs/lighttpd.conf +0 -54
  90. data/doc/guides/html/2_2_release_notes.html +0 -1185
  91. data/doc/guides/html/actioncontroller_basics.html +0 -1270
  92. data/doc/guides/html/activerecord_validations_callbacks.html +0 -749
  93. data/doc/guides/html/association_basics.html +0 -2585
  94. data/doc/guides/html/authors.html +0 -240
  95. data/doc/guides/html/benchmarking_and_profiling.html +0 -1018
  96. data/doc/guides/html/caching_with_rails.html +0 -583
  97. data/doc/guides/html/command_line.html +0 -434
  98. data/doc/guides/html/configuring.html +0 -438
  99. data/doc/guides/html/creating_plugins.html +0 -1594
  100. data/doc/guides/html/debugging_rails_applications.html +0 -1175
  101. data/doc/guides/html/finders.html +0 -1090
  102. data/doc/guides/html/form_helpers.html +0 -638
  103. data/doc/guides/html/getting_started_with_rails.html +0 -2066
  104. data/doc/guides/html/index.html +0 -349
  105. data/doc/guides/html/layouts_and_rendering.html +0 -1406
  106. data/doc/guides/html/migrations.html +0 -921
  107. data/doc/guides/html/routing_outside_in.html +0 -2213
  108. data/doc/guides/html/security.html +0 -1346
  109. data/doc/guides/html/testing_rails_applications.html +0 -1859
  110. data/doc/guides/source/2_2_release_notes.txt +0 -435
  111. data/doc/guides/source/actioncontroller_basics/changelog.txt +0 -5
  112. data/doc/guides/source/actioncontroller_basics/cookies.txt +0 -34
  113. data/doc/guides/source/actioncontroller_basics/csrf.txt +0 -32
  114. data/doc/guides/source/actioncontroller_basics/filters.txt +0 -119
  115. data/doc/guides/source/actioncontroller_basics/http_auth.txt +0 -24
  116. data/doc/guides/source/actioncontroller_basics/index.txt +0 -40
  117. data/doc/guides/source/actioncontroller_basics/introduction.txt +0 -9
  118. data/doc/guides/source/actioncontroller_basics/methods.txt +0 -39
  119. data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +0 -14
  120. data/doc/guides/source/actioncontroller_basics/params.txt +0 -93
  121. data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +0 -43
  122. data/doc/guides/source/actioncontroller_basics/rescue.txt +0 -67
  123. data/doc/guides/source/actioncontroller_basics/session.txt +0 -187
  124. data/doc/guides/source/actioncontroller_basics/streaming.txt +0 -91
  125. data/doc/guides/source/actioncontroller_basics/verification.txt +0 -40
  126. data/doc/guides/source/active_record_basics.txt +0 -181
  127. data/doc/guides/source/activerecord_validations_callbacks.txt +0 -404
  128. data/doc/guides/source/association_basics.txt +0 -1840
  129. data/doc/guides/source/authors.txt +0 -39
  130. data/doc/guides/source/benchmarking_and_profiling/appendix.txt +0 -95
  131. data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +0 -105
  132. data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +0 -185
  133. data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +0 -27
  134. data/doc/guides/source/benchmarking_and_profiling/index.txt +0 -242
  135. data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +0 -179
  136. data/doc/guides/source/benchmarking_and_profiling/statistics.txt +0 -57
  137. data/doc/guides/source/caching_with_rails.txt +0 -367
  138. data/doc/guides/source/command_line.txt +0 -147
  139. data/doc/guides/source/configuring.txt +0 -225
  140. data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +0 -191
  141. data/doc/guides/source/creating_plugins/appendix.txt +0 -46
  142. data/doc/guides/source/creating_plugins/controllers.txt +0 -59
  143. data/doc/guides/source/creating_plugins/core_ext.txt +0 -123
  144. data/doc/guides/source/creating_plugins/custom_route.txt +0 -69
  145. data/doc/guides/source/creating_plugins/gem.txt +0 -1
  146. data/doc/guides/source/creating_plugins/generator_method.txt +0 -89
  147. data/doc/guides/source/creating_plugins/helpers.txt +0 -51
  148. data/doc/guides/source/creating_plugins/index.txt +0 -52
  149. data/doc/guides/source/creating_plugins/migration_generator.txt +0 -156
  150. data/doc/guides/source/creating_plugins/models.txt +0 -76
  151. data/doc/guides/source/creating_plugins/odds_and_ends.txt +0 -69
  152. data/doc/guides/source/creating_plugins/test_setup.txt +0 -230
  153. data/doc/guides/source/debugging_rails_applications.txt +0 -733
  154. data/doc/guides/source/finders.txt +0 -668
  155. data/doc/guides/source/form_helpers.txt +0 -345
  156. data/doc/guides/source/getting_started_with_rails.txt +0 -1256
  157. data/doc/guides/source/images/belongs_to.png +0 -0
  158. data/doc/guides/source/images/bullet.gif +0 -0
  159. data/doc/guides/source/images/csrf.png +0 -0
  160. data/doc/guides/source/images/habtm.png +0 -0
  161. data/doc/guides/source/images/has_many.png +0 -0
  162. data/doc/guides/source/images/has_many_through.png +0 -0
  163. data/doc/guides/source/images/has_one.png +0 -0
  164. data/doc/guides/source/images/has_one_through.png +0 -0
  165. data/doc/guides/source/images/header_backdrop.png +0 -0
  166. data/doc/guides/source/images/icons/README +0 -5
  167. data/doc/guides/source/images/icons/callouts/1.png +0 -0
  168. data/doc/guides/source/images/icons/callouts/10.png +0 -0
  169. data/doc/guides/source/images/icons/callouts/11.png +0 -0
  170. data/doc/guides/source/images/icons/callouts/12.png +0 -0
  171. data/doc/guides/source/images/icons/callouts/13.png +0 -0
  172. data/doc/guides/source/images/icons/callouts/14.png +0 -0
  173. data/doc/guides/source/images/icons/callouts/15.png +0 -0
  174. data/doc/guides/source/images/icons/callouts/2.png +0 -0
  175. data/doc/guides/source/images/icons/callouts/3.png +0 -0
  176. data/doc/guides/source/images/icons/callouts/4.png +0 -0
  177. data/doc/guides/source/images/icons/callouts/5.png +0 -0
  178. data/doc/guides/source/images/icons/callouts/6.png +0 -0
  179. data/doc/guides/source/images/icons/callouts/7.png +0 -0
  180. data/doc/guides/source/images/icons/callouts/8.png +0 -0
  181. data/doc/guides/source/images/icons/callouts/9.png +0 -0
  182. data/doc/guides/source/images/icons/caution.png +0 -0
  183. data/doc/guides/source/images/icons/example.png +0 -0
  184. data/doc/guides/source/images/icons/home.png +0 -0
  185. data/doc/guides/source/images/icons/important.png +0 -0
  186. data/doc/guides/source/images/icons/next.png +0 -0
  187. data/doc/guides/source/images/icons/note.png +0 -0
  188. data/doc/guides/source/images/icons/prev.png +0 -0
  189. data/doc/guides/source/images/icons/tip.png +0 -0
  190. data/doc/guides/source/images/icons/up.png +0 -0
  191. data/doc/guides/source/images/icons/warning.png +0 -0
  192. data/doc/guides/source/images/polymorphic.png +0 -0
  193. data/doc/guides/source/images/rails_logo_remix.gif +0 -0
  194. data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
  195. data/doc/guides/source/images/session_fixation.png +0 -0
  196. data/doc/guides/source/index.txt +0 -118
  197. data/doc/guides/source/layouts_and_rendering.txt +0 -982
  198. data/doc/guides/source/migrations/anatomy_of_a_migration.txt +0 -85
  199. data/doc/guides/source/migrations/changelog.txt +0 -5
  200. data/doc/guides/source/migrations/creating_a_migration.txt +0 -109
  201. data/doc/guides/source/migrations/foreign_keys.txt +0 -8
  202. data/doc/guides/source/migrations/index.txt +0 -22
  203. data/doc/guides/source/migrations/rakeing_around.txt +0 -111
  204. data/doc/guides/source/migrations/scheming.txt +0 -47
  205. data/doc/guides/source/migrations/using_models_in_migrations.txt +0 -46
  206. data/doc/guides/source/migrations/writing_a_migration.txt +0 -159
  207. data/doc/guides/source/routing_outside_in.txt +0 -986
  208. data/doc/guides/source/security.txt +0 -984
  209. data/doc/guides/source/stylesheets/base.css +0 -358
  210. data/doc/guides/source/stylesheets/forms.css +0 -35
  211. data/doc/guides/source/stylesheets/more.css +0 -82
  212. data/doc/guides/source/templates/guides.html.erb +0 -97
  213. data/doc/guides/source/templates/inline.css +0 -165
  214. data/doc/guides/source/testing_rails_applications.txt +0 -995
  215. data/helpers/application.rb +0 -15
  216. data/lib/commands/performance/request.rb +0 -6
  217. data/lib/commands/process/inspector.rb +0 -68
  218. data/lib/commands/process/reaper.rb +0 -149
  219. data/lib/commands/process/spawner.rb +0 -219
  220. data/lib/commands/process/spinner.rb +0 -57
  221. data/lib/commands/servers/base.rb +0 -31
  222. data/lib/commands/servers/lighttpd.rb +0 -94
  223. data/lib/commands/servers/mongrel.rb +0 -69
  224. data/lib/commands/servers/new_mongrel.rb +0 -16
  225. data/lib/commands/servers/thin.rb +0 -25
  226. data/lib/commands/servers/webrick.rb +0 -66
  227. data/lib/rails/mongrel_server/commands.rb +0 -342
  228. data/lib/rails/mongrel_server/handler.rb +0 -55
  229. data/lib/rails/rack/logger.rb +0 -28
@@ -1,39 +0,0 @@
1
- About the Authors
2
- =================
3
-
4
- .Frederick Cheung
5
- [[fcheung]]
6
- ***********************************************************
7
- Frederick Cheung is Chief Wizard at Texperts where he has been using Rails since 2006.
8
- He is based in Cambridge (UK) and when not consuming fine ales he blogs at http://www.spacevatican.org[spacevatican.org].
9
- ***********************************************************
10
-
11
- .Mike Gunderloy
12
- [[mgunderloy]]
13
- ***********************************************************
14
- Mike Gunderloy is an independent consultant who brings 25 years of experience in a variety of languages to bear on his current
15
- work with Rails. His near-daily links and other blogging can be found at http://afreshcup.com[A Fresh Cup].
16
- ***********************************************************
17
-
18
- .Emilio Tagua
19
- [[miloops]]
20
- ***********************************************************
21
- Emilio Tagua -- a.k.a. miloops -- is an Argentinian entrepreneur, developer, open source contributor and Rails evangelist.
22
- Cofounder of http://www.eventioz.com[Eventioz]. He has been using Rails since 2006 and contributing since early 2008.
23
- Can be found at gmail, twitter, freenode, everywhere as miloops.
24
- ***********************************************************
25
-
26
- .Heiko Webers
27
- [[hawe]]
28
- ***********************************************************
29
- Heiko Webers is the founder of http://www.bauland42.de[bauland42], a German web application security consulting and development
30
- company focused on Ruby on Rails. He blogs at http://www.rorsecurity.info. After 10 years of desktop application development,
31
- Heiko has rarely looked back.
32
- ***********************************************************
33
-
34
- .Tore Darell
35
- [[toretore]]
36
- ***********************************************************
37
- Tore Darell is an independent developer based in Menton, France who specialises in cruft-free web applications using Ruby, Rails
38
- and unobtrusive JavaScript. His home on the internet is his blog http://tore.darell.no/[Sneaky Abstractions].
39
- ***********************************************************
@@ -1,95 +0,0 @@
1
- == Other Profiling Tools ==
2
-
3
- There are a lot of great profiling tools out there. Some free, some not so free. This is a sort list detailing some of them.
4
-
5
- === httperf ===
6
- http://www.hpl.hp.com/research/linux/httperf/[http://www.hpl.hp.com/research/linux/httperf/]
7
-
8
- A necessary tool in your arsenal. Very useful for load testing your website.
9
-
10
- #TODO write and link to a short article on how to use httperf. Anybody have a good tutorial availble.
11
-
12
-
13
- === Rails Analyzer ===
14
-
15
- The Rails Analyzer project contains a collection of tools for Rails. It's open source and pretty speedy. It's not being actively worked on but is still contains some very useful tools.
16
-
17
- * The Production Log Analyzer examines Rails log files and gives back a report. It also includes action_grep which will give you all log results for a particular action.
18
-
19
- * The Action Profiler similar to Ruby-Prof profiler.
20
-
21
- * rails_stat which gives a live counter of requests per second of a running Rails app.
22
-
23
- * The SQL Dependency Grapher allows you to visualize the frequency of table dependencies in a Rails application.
24
-
25
- Their project homepage can be found at http://rails-analyzer.rubyforge.org/[http://rails-analyzer.rubyforge.org/]
26
-
27
- The one major caveat is that it needs your log to be in a different format from how rails sets it up specifically SyslogLogger.
28
-
29
-
30
- ==== SyslogLogger ====
31
-
32
- SyslogLogger is a Logger work-alike that logs via syslog instead of to a file. You can add SyslogLogger to your Rails production environment to aggregate logs between multiple machines.
33
-
34
- More information can be found out at http://rails-analyzer.rubyforge.org/hacks/classes/SyslogLogger.html[http://rails-analyzer.rubyforge.org/hacks/classes/SyslogLogger.html]
35
-
36
- If you don't have access to your machines root system or just want something a bit easier to implement there is also a module developed by Geoffrey Grosenbach
37
-
38
- ==== A Hodel 3000 Compliant Logger for the Rest of Us ====
39
-
40
- Directions taken from
41
- http://topfunky.net/svn/plugins/hodel_3000_compliant_logger/lib/hodel_3000_compliant_logger.rb[link to module file]
42
-
43
- Just put the module in your lib directory and add this to your environment.rb in it's config portion.
44
-
45
- ------------------------------------------------------------
46
- require 'hodel_3000_compliant_logger'
47
- config.logger = Hodel3000CompliantLogger.new(config.log_path)
48
- -------------------------------------------------------------
49
-
50
- It's that simple. Your log output on restart should look like this.
51
-
52
- .Hodel 3000 Example
53
- ----------------------------------------------------------------------------
54
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]:
55
- Parameters: {"action"=>"shipping", "controller"=>"checkout"}
56
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]: 
57
- [4;36;1mBook Columns (0.003155) SHOW FIELDS FROM `books`
58
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]: 
59
- [4;35;1mBook Load (0.000881) SELECT * FROM `books` WHERE (`books`.`id` = 1 AND (`books`.`sold` = 1)) 
60
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]: 
61
- [4;36;1mShippingAddress Columns (0.002683) SHOW FIELDS FROM `shipping_addresses`
62
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]: 
63
- [4;35;1mBook Load (0.000362) SELECT ounces FROM `books` WHERE (`books`.`id` = 1) 
64
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]:
65
- Rendering template within layouts/application
66
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]:
67
- Rendering checkout/shipping
68
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]: 
69
- [4;36;1mBook Load (0.000548) SELECT * FROM `books`
70
- WHERE (sold = 0) LIMIT 3
71
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]: 
72
- [4;35;1mAuthor Columns (0.002571) SHOW FIELDS FROM `authors`
73
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]:
74
- Author Load (0.000811) SELECT * FROM `authors` WHERE (`authors`.`id` = 1) 
75
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]:
76
- Rendered store/_new_books (0.01358)
77
- Jul 15 11:45:43 matthew-bergmans-macbook-pro-15 rails[16207]:
78
- Completed in 0.37297 (2 reqs/sec) | Rendering: 0.02971 (7%) | DB: 0.01697 (4%) | 200 OK [https://secure.jeffbooks/checkout/shipping]
79
- ----------------------------------------------------------------------------
80
-
81
- === Palmist ===
82
- An open source mysql query analyzer. Full featured and easy to work with. Also requires Hodel 3000
83
- http://www.flyingmachinestudios.com/projects/[http://www.flyingmachinestudios.com/projects/]
84
-
85
- === New Relic ===
86
- http://www.newrelic.com/[http://www.newrelic.com/]
87
-
88
- Pretty nifty performance tools, pricey though. They do have a basic free
89
- service both for when in development and when you put your application into production. Very simple installation and signup.
90
-
91
- #TODO more in-depth without being like an advertisement.
92
-
93
- ==== Manage ====
94
-
95
- Like new relic a production monitoring tool.
@@ -1,105 +0,0 @@
1
- == Real Life Example ==
2
- === The setup ===
3
-
4
- So I have been building this application for the last month and feel pretty good about the ruby code. I'm readying it for beta testers when I discover to my shock that with less then twenty people it starts to crash. It's a pretty simple Ecommerce site so I'm very confused by what I'm seeing. On running looking through my log files I find to my shock that the lowest time for a page run is running around 240 ms. My database finds aren't the problems so I'm lost as to what is happening to cause all this. Lets run a benchmark.
5
-
6
-
7
- [source, ruby]
8
- ----------------------------------------------------------------------------
9
- class HomepageTest < ActionController::PerformanceTest
10
- # Replace this with your real tests.
11
- def test_homepage
12
- get '/'
13
- end
14
- end
15
- ----------------------------------------------------------------------------
16
-
17
- .Output
18
- ----------------------------------------------------------------------------
19
- HomepageTest#test_homepage (115 ms warmup)
20
- process_time: 591 ms
21
- memory: 3052.90 KB
22
- objects: 59471
23
- ----------------------------------------------------------------------------
24
-
25
-
26
-
27
- Obviously something is very very wrong here. 3052.90 Kb to load my minimal homepage. For Comparison for another site running well I get this for my homepage test.
28
-
29
- .Default
30
- ----------------------------------------------------------------------------
31
- HomepageTest#test_homepage (19 ms warmup)
32
- process_time: 26 ms
33
- memory: 298.79 KB
34
- objects: 1917
35
- ----------------------------------------------------------------------------
36
-
37
- that over a factor of ten difference. Lets look at our flat process time file to see if anything pops out at us.
38
-
39
- .Process time
40
- ----------------------------------------------------------------------------
41
- 20.73 0.39 0.12 0.00 0.27 420 Pathname#cleanpath_aggressive
42
- 17.07 0.14 0.10 0.00 0.04 3186 Pathname#chop_basename
43
- 6.47 0.06 0.04 0.00 0.02 6571 Kernel#===
44
- 5.04 0.06 0.03 0.00 0.03 840 Pathname#initialize
45
- 5.03 0.05 0.03 0.00 0.02 4 ERB::Compiler::ExplicitScanner#scan
46
- 4.51 0.03 0.03 0.00 0.00 9504 String#==
47
- 2.94 0.46 0.02 0.00 0.44 1393 String#gsub
48
- 2.66 0.09 0.02 0.00 0.07 480 Array#each
49
- 2.46 0.01 0.01 0.00 0.00 3606 Regexp#to_s
50
- ----------------------------------------------------------------------------
51
-
52
- Yes indeed we seem to have found the problem. Pathname#cleanpath_aggressive is taking nearly a quarter our process time and Pathname#chop_basename another 17%. From here I do a few more benchmarks to make sure that these processes are slowing down the other pages. They are so now I know what I must do. *If we can get rid of or shorten these processes we can make our pages run much quicker*.
53
-
54
- Now both of these are main ruby processes so are goal right now is to find out what other process is calling them. Glancing at our Graph file I see that #cleanpath is calling #cleanpath_aggressive. #cleanpath is being called by String#gsub and from there some html template errors. But my page seems to be rendering fine. why would it be calling template errors. I'm decide to check my object flat file to see if I can find any more information.
55
-
56
- .Objects Created
57
- ----------------------------------------------------------------------------
58
- 20.74 34800.00 12324.00 0.00 22476.00 420 Pathname#cleanpath_aggressive
59
- 16.79 18696.00 9978.00 0.00 8718.00 3186 Pathname#chop_basename
60
- 11.47 13197.00 6813.00 0.00 6384.00 480 Array#each
61
- 8.51 41964.00 5059.00 0.00 36905.00 1386 String#gsub
62
- 6.07 3606.00 3606.00 0.00 0.00 3606 Regexp#to_s
63
- ----------------------------------------------------------------------------
64
-
65
- nope nothing new here. Lets look at memory usage
66
-
67
- .Memory Consuption
68
- ----------------------------------------------------------------------------
69
- 40.17 1706.80 1223.70 0.00 483.10 3186 Pathname#chop_basename
70
- 14.92 454.47 454.47 0.00 0.00 3606 Regexp#to_s
71
- 7.09 2381.36 215.99 0.00 2165.37 1386 String#gsub
72
- 5.08 231.19 154.73 0.00 76.46 420 Pathname#prepend_prefix
73
- 2.34 71.35 71.35 0.00 0.00 1265 String#initialize_copy
74
- ----------------------------------------------------------------------------
75
-
76
- Ok so it seems Regexp#to_s is the second costliest process. At this point I try to figure out what could be calling a regular expression cause I very rarely use them. Going over my standard layout I discover at the top.
77
-
78
-
79
- [source, html]
80
- ----------------------------------------------------------------------------
81
- <%if request.env["HTTP_USER_AGENT"].match(/Opera/)%>
82
- <%= stylesheet_link_tag "opera" %>
83
- <% end %>
84
- ----------------------------------------------------------------------------
85
-
86
- That's wrong. I mistakenly am using a search function for a simple compare function. Lets fix that.
87
-
88
-
89
- [source, html]
90
- ----------------------------------------------------------------------------
91
- <%if request.env["HTTP_USER_AGENT"] =~ /Opera/%>
92
- <%= stylesheet_link_tag "opera" %>
93
- <% end %>
94
- ----------------------------------------------------------------------------
95
-
96
- I'll now try my test again.
97
-
98
- ----------------------------------------------------------------------------
99
- process_time: 75 ms
100
- memory: 519.95 KB
101
- objects: 6537
102
- ----------------------------------------------------------------------------
103
-
104
- Much better. The problem has been solved. Now I should have realized earlier due to the String#gsub that my problem had to be with reqexp serch function but such knowledge comes with time. Looking through the mass output data is a skill.
105
-
@@ -1,185 +0,0 @@
1
- == Performance Testing Built into Rails ==
2
-
3
- As of June 20, 2008 edge rails has had a new type of Unit test geared towards profiling. Of course like most great things, getting it working takes bit of work. The test relies on statistics gathered from the Garbage Collection that isn't readily available from standard compiled ruby. There is a patch located at http://rubyforge.org/tracker/download.php/1814/7062/17676/3291/ruby186gc.patch[http://rubyforge.org/tracker/download.php/1814/7062/17676/3291/ruby186gc.patch]
4
-
5
- Also the test requires a new version of Ruby-Prof version of 0.6.1. It is not readily available at the moment and can most easily be found as a tarball on github. It's repository is located at git://github.com/jeremy/ruby-prof.git.
6
-
7
- What follows is a description of how to set up an alternative ruby install to use these features
8
-
9
- === Compiling the Interpreter ===
10
-
11
-
12
- [source, shell]
13
- ----------------------------------------------------------------------------
14
- [User ~]$ mkdir rubygc
15
- [User ~]$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz
16
- [User ~]$ tar -xzvf ruby-1.8.6-p111.tar.gz
17
- [User ~]$ cd ruby-1.8.6-p111
18
- [User ruby-1.8.6-p111]$ curl http://rubyforge.org/tracker/download.php/1814/7062/17676/3291/ruby186gc.patch | patch -p0
19
-
20
- #I like putting my alternative ruby builds in an opt directory, set the prefix to where ever you feel is most comfortable.
21
-
22
- [User ruby-1.8.6-p111]$ ./configure --prefix=/opt/rubygc
23
- [User ruby-1.8.6-p111]$ sudo make && make install
24
- ----------------------------------------------------------------------------
25
-
26
- Add the following lines in your \~/.profile or \~/.bash\_login for convenience.
27
-
28
- ----------------------------------------------------------------------------
29
- alias gcruby='/opt/rubygc/rubygc/bin/ruby'
30
- alias gcrake='/opt/rubygc/rubygc/bin/rake'
31
- alias gcgem='/opt/rubygc/rubygc/bin/gem'
32
- alias gcirb=/opt/rubygc/rubygc/bin/irb'
33
- alias gcrails='/opt/rubygc/rubygc/bin/rails'
34
- ----------------------------------------------------------------------------
35
-
36
- === Installing RubyGems ===
37
-
38
- Next we need to install rubygems and rails so that we can use the interpreter properly.
39
-
40
-
41
- [source, shell]
42
- ----------------------------------------------------------------------------
43
- [User ~]$ wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
44
- [User ~]$ tar -xzvf rubygems-1.2.0.tgz
45
- [User ~]$ cd rubygems-1.2.0
46
- [User rubygems-1.2.0]$ gcruby setup.rb
47
- [User rubygems-1.2.0]$ cd ~
48
- [User ~]$ gcgem install rake
49
- [User ~]$ gcgem install mysql
50
- [User ~]$ gcgem install rails
51
- ----------------------------------------------------------------------------
52
-
53
- If installing mysql gem fails ( like it did for me ), you will have to manually install it :
54
-
55
- [source, shell]
56
- ----------------------------------------------------------------------------
57
- [User ~]$ cd /Users/lifo/rubygc/lib/ruby/gems/1.8/gems/mysql-2.7/
58
- [User mysql-2.7]$ gcruby extconf.rb --with-mysql-config
59
- [User mysql-2.7]$ make && make install
60
- ----------------------------------------------------------------------------
61
-
62
- === Installing Jeremy Kemper's ruby-prof ===
63
-
64
- We are in the home stretch. All we need now is ruby-proff 0.6.1
65
-
66
-
67
- [source, shell]
68
- ----------------------------------------------------------------------------
69
- [User ~]$ git clone git://github.com/jeremy/ruby-prof.git
70
- [User ~]$ cd ruby-prof/
71
- [User ruby-prof (master)]$ gcrake gem
72
- [User ruby-prof (master)]$ gcgem install pkg/ruby-prof-0.6.1.gem
73
- ----------------------------------------------------------------------------
74
-
75
- Finished, go get yourself a power drink!
76
-
77
- === Ok so I lied, a few more things we need to do ===
78
-
79
- You have everything we need to start profiling through rails Unit Testing. Unfortunately we are still missing a few files. I'm going to do the next step on a fresh Rails app, but it will work just as well on developmental 2.1 rails application.
80
-
81
- ==== The Rails App ====
82
-
83
- First I need to generate a rail app
84
-
85
- [source, shell]
86
- ----------------------------------------------------------------------------
87
- [User ~]$ gcrails profiling_tester -d mysql
88
- [User ~]$ cd profiling_tester
89
- [User profiling_tester]$ script/generate scaffold item name:string
90
- [User profiling_tester]$ gcrake db:create:all
91
- [User profiling_tester]$ gcrake db:migrate
92
- [User profiling_tester (master)]$ rm public/index.html
93
- ----------------------------------------------------------------------------
94
-
95
- Now I'm going to init it as a git repository and add edge rails as a submodule to it.
96
-
97
- [source, shell]
98
- ----------------------------------------------------------------------------
99
- [User profiling_tester]$ git init
100
- [User profiling_tester (master)]$ git submodule add git://github.com/rails/rails.git vendor/rails
101
- ----------------------------------------------------------------------------
102
-
103
- Finally we want to change config.cache_classes to true in our environment.rb
104
-
105
- ----------------------------------------------------------------------------
106
- config.cache_classes = true
107
- ----------------------------------------------------------------------------
108
-
109
- If we don't cache classes, then the time Rails spends reloading and compiling our models and controllers will confound our results. Obviously we will try to make our test setup as similar as possible to our production environment.
110
-
111
- === Generating and Fixing the tests ===
112
-
113
- Ok next we need to generate the test script.
114
-
115
- [source, shell]
116
- ----------------------------------------------------------------------------
117
- [User profiling_tester (master)]$ script/generate performance_test homepage
118
- ----------------------------------------------------------------------------
119
-
120
- This will generate _test/performance/homepage_test.rb_ for you. However, as I have generated the project using Rails 2.1 gem, we'll need to manually generate one more file before we can go ahead.
121
-
122
- We need to put the following inside _test/performance/test_helper.rb
123
-
124
-
125
- [source, ruby]
126
- ----------------------------------------------------------------------------
127
- require 'test_helper'
128
- require 'performance_test_help'
129
- ----------------------------------------------------------------------------
130
-
131
- Though this depends where you run your tests from and your system config. I myself run my tests from the Application root directory
132
-
133
- so instead of
134
-
135
- [source, ruby]
136
- ----------------------------------------------------------------------------
137
- require 'test_helper'
138
-
139
- #I have
140
-
141
- require 'test/test_helper'
142
- ----------------------------------------------------------------------------
143
-
144
- Also I needed to change homepage_test.rb to reflect this also
145
-
146
- [source, ruby]
147
- ----------------------------------------------------------------------------
148
- require 'test/performance/test_helper.rb'
149
- ----------------------------------------------------------------------------
150
-
151
- === Testing ===
152
-
153
- #TODO is there some way to compare multiple request at once like ruby_analyze
154
-
155
- Now, if we look at the generated performance test ( one we generated using _script/generate performance_test_ ), it'll look something like :
156
-
157
- [source, ruby]
158
- ----------------------------------------------------------------------------
159
- .require 'performance/test_helper'
160
-
161
- class HomepageTest < ActionController::PerformanceTest
162
- # Replace this with your real tests.
163
- def test_homepage
164
- get '/'
165
- end
166
- end
167
- ----------------------------------------------------------------------------
168
-
169
-
170
- The format looks very similar to that of an integration test. And guess what, that's what it is. But that doesn't stop you from testing your Model methods. You could very well write something like :
171
-
172
- [source, ruby]
173
- ----------------------------------------------------------------------------
174
- require 'performance/test_helper'
175
-
176
- class UserModelTest < ActionController::PerformanceTest
177
- # Replace this with your real tests.
178
- def test_slow_find
179
- User.this_takes_shlong_to_run
180
- end
181
- end
182
- ----------------------------------------------------------------------------
183
-
184
-
185
- Which is very useful way to profile individual processes.
@@ -1,27 +0,0 @@
1
- == Get Yourself a Game Plan ==
2
-
3
- You end up dealing with a large amount of data whenever you profile an application. It's crucial to use a rigorous approach to analyzing your application's performance else fail miserably in a vortex of numbers. This leads us to -
4
-
5
- === The Analysis Process ===
6
-
7
- I’m going to give an example methodology for conducting your benchmarking and profiling on an application. It is based on your typical scientific method.
8
-
9
- For something as complex as Benchmarking you need to take any methodology with a grain of salt but there are some basic strictures that you can depend on.
10
-
11
- Formulate a question you need to answer which is simple, tests the smallest measurable thing possible, and is exact. This is typically the hardest part of the experiment. From there some steps that you should follow are.
12
-
13
- * Develop a set of variables and processes to measure in order to answer this question!
14
- * Profile based on the question and variables. Key problems to avoid when designing this experiment are:
15
- - Confounding: Test one thing at a time, keep everything the same so you don't poison the data with uncontrolled processes.
16
- - Cross Contamination: Make sure that runs from one test do not harm the other tests.
17
- - Steady States: If you’re testing long running process. You must take the ramp up time and performance hit into your initial measurements.
18
- - Sampling Error: Data should perform have a steady variance or range. If you get wild swings or sudden spikes, etc. then you must either account for the reason why or you have a sampling error.
19
- - Measurement Error: Aka Human error, always go through your calculations at least twice to make sure there are no mathematical errors. .
20
- * Do a small run of the experiment to verify the design.
21
- * Use the small run to determine a proper sample size.
22
- * Run the test.
23
- * Perform the analysis on the results and determine where to go from there.
24
-
25
- Note: Even though we are using the typical scientific method; developing a hypothesis is not always useful in terms of profiling.
26
-
27
-