rails 2.2.2 → 3.0.0
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.
- data/bin/rails +8 -18
- metadata +118 -452
- data/CHANGELOG +0 -2071
- data/MIT-LICENSE +0 -20
- data/README +0 -256
- data/Rakefile +0 -411
- data/bin/about +0 -4
- data/bin/console +0 -3
- data/bin/dbconsole +0 -3
- data/bin/destroy +0 -3
- data/bin/generate +0 -3
- data/bin/performance/benchmarker +0 -3
- data/bin/performance/profiler +0 -3
- data/bin/performance/request +0 -3
- data/bin/plugin +0 -3
- data/bin/process/inspector +0 -3
- data/bin/process/reaper +0 -3
- data/bin/process/spawner +0 -3
- data/bin/runner +0 -3
- data/bin/server +0 -3
- data/builtin/rails_info/rails/info.rb +0 -125
- data/builtin/rails_info/rails/info_controller.rb +0 -9
- data/builtin/rails_info/rails/info_helper.rb +0 -2
- data/builtin/rails_info/rails_info_controller.rb +0 -2
- data/config.ru +0 -17
- data/configs/apache.conf +0 -40
- data/configs/databases/frontbase.yml +0 -28
- data/configs/databases/ibm_db.yml +0 -62
- data/configs/databases/mysql.yml +0 -57
- data/configs/databases/oracle.yml +0 -39
- data/configs/databases/postgresql.yml +0 -51
- data/configs/databases/sqlite2.yml +0 -19
- data/configs/databases/sqlite3.yml +0 -22
- data/configs/empty.log +0 -0
- data/configs/initializers/inflections.rb +0 -10
- data/configs/initializers/mime_types.rb +0 -5
- data/configs/initializers/new_rails_defaults.rb +0 -17
- data/configs/lighttpd.conf +0 -54
- data/configs/locales/en.yml +0 -5
- data/configs/routes.rb +0 -43
- data/dispatches/dispatch.fcgi +0 -24
- data/dispatches/dispatch.rb +0 -10
- data/dispatches/gateway.cgi +0 -97
- data/doc/README_FOR_APP +0 -5
- data/doc/guides/html/2_2_release_notes.html +0 -1185
- data/doc/guides/html/actioncontroller_basics.html +0 -1270
- data/doc/guides/html/activerecord_validations_callbacks.html +0 -749
- data/doc/guides/html/association_basics.html +0 -2585
- data/doc/guides/html/authors.html +0 -240
- data/doc/guides/html/benchmarking_and_profiling.html +0 -1018
- data/doc/guides/html/caching_with_rails.html +0 -583
- data/doc/guides/html/command_line.html +0 -434
- data/doc/guides/html/configuring.html +0 -438
- data/doc/guides/html/creating_plugins.html +0 -1594
- data/doc/guides/html/debugging_rails_applications.html +0 -1175
- data/doc/guides/html/finders.html +0 -1090
- data/doc/guides/html/form_helpers.html +0 -638
- data/doc/guides/html/getting_started_with_rails.html +0 -2066
- data/doc/guides/html/index.html +0 -349
- data/doc/guides/html/layouts_and_rendering.html +0 -1406
- data/doc/guides/html/migrations.html +0 -921
- data/doc/guides/html/routing_outside_in.html +0 -2213
- data/doc/guides/html/security.html +0 -1346
- data/doc/guides/html/testing_rails_applications.html +0 -1859
- data/doc/guides/source/2_2_release_notes.txt +0 -435
- data/doc/guides/source/actioncontroller_basics/changelog.txt +0 -5
- data/doc/guides/source/actioncontroller_basics/cookies.txt +0 -34
- data/doc/guides/source/actioncontroller_basics/csrf.txt +0 -32
- data/doc/guides/source/actioncontroller_basics/filters.txt +0 -119
- data/doc/guides/source/actioncontroller_basics/http_auth.txt +0 -24
- data/doc/guides/source/actioncontroller_basics/index.txt +0 -40
- data/doc/guides/source/actioncontroller_basics/introduction.txt +0 -9
- data/doc/guides/source/actioncontroller_basics/methods.txt +0 -39
- data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +0 -14
- data/doc/guides/source/actioncontroller_basics/params.txt +0 -93
- data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +0 -43
- data/doc/guides/source/actioncontroller_basics/rescue.txt +0 -67
- data/doc/guides/source/actioncontroller_basics/session.txt +0 -187
- data/doc/guides/source/actioncontroller_basics/streaming.txt +0 -91
- data/doc/guides/source/actioncontroller_basics/verification.txt +0 -40
- data/doc/guides/source/active_record_basics.txt +0 -181
- data/doc/guides/source/activerecord_validations_callbacks.txt +0 -404
- data/doc/guides/source/association_basics.txt +0 -1840
- data/doc/guides/source/authors.txt +0 -39
- data/doc/guides/source/benchmarking_and_profiling/appendix.txt +0 -95
- data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +0 -105
- data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +0 -185
- data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +0 -27
- data/doc/guides/source/benchmarking_and_profiling/index.txt +0 -242
- data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +0 -179
- data/doc/guides/source/benchmarking_and_profiling/statistics.txt +0 -57
- data/doc/guides/source/caching_with_rails.txt +0 -367
- data/doc/guides/source/command_line.txt +0 -147
- data/doc/guides/source/configuring.txt +0 -225
- data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +0 -191
- data/doc/guides/source/creating_plugins/appendix.txt +0 -46
- data/doc/guides/source/creating_plugins/controllers.txt +0 -59
- data/doc/guides/source/creating_plugins/core_ext.txt +0 -123
- data/doc/guides/source/creating_plugins/custom_route.txt +0 -69
- data/doc/guides/source/creating_plugins/gem.txt +0 -1
- data/doc/guides/source/creating_plugins/generator_method.txt +0 -89
- data/doc/guides/source/creating_plugins/helpers.txt +0 -51
- data/doc/guides/source/creating_plugins/index.txt +0 -52
- data/doc/guides/source/creating_plugins/migration_generator.txt +0 -156
- data/doc/guides/source/creating_plugins/models.txt +0 -76
- data/doc/guides/source/creating_plugins/odds_and_ends.txt +0 -69
- data/doc/guides/source/creating_plugins/test_setup.txt +0 -230
- data/doc/guides/source/debugging_rails_applications.txt +0 -733
- data/doc/guides/source/finders.txt +0 -668
- data/doc/guides/source/form_helpers.txt +0 -345
- data/doc/guides/source/getting_started_with_rails.txt +0 -1256
- data/doc/guides/source/images/belongs_to.png +0 -0
- data/doc/guides/source/images/bullet.gif +0 -0
- data/doc/guides/source/images/csrf.png +0 -0
- data/doc/guides/source/images/habtm.png +0 -0
- data/doc/guides/source/images/has_many.png +0 -0
- data/doc/guides/source/images/has_many_through.png +0 -0
- data/doc/guides/source/images/has_one.png +0 -0
- data/doc/guides/source/images/has_one_through.png +0 -0
- data/doc/guides/source/images/header_backdrop.png +0 -0
- data/doc/guides/source/images/icons/README +0 -5
- data/doc/guides/source/images/icons/callouts/1.png +0 -0
- data/doc/guides/source/images/icons/callouts/10.png +0 -0
- data/doc/guides/source/images/icons/callouts/11.png +0 -0
- data/doc/guides/source/images/icons/callouts/12.png +0 -0
- data/doc/guides/source/images/icons/callouts/13.png +0 -0
- data/doc/guides/source/images/icons/callouts/14.png +0 -0
- data/doc/guides/source/images/icons/callouts/15.png +0 -0
- data/doc/guides/source/images/icons/callouts/2.png +0 -0
- data/doc/guides/source/images/icons/callouts/3.png +0 -0
- data/doc/guides/source/images/icons/callouts/4.png +0 -0
- data/doc/guides/source/images/icons/callouts/5.png +0 -0
- data/doc/guides/source/images/icons/callouts/6.png +0 -0
- data/doc/guides/source/images/icons/callouts/7.png +0 -0
- data/doc/guides/source/images/icons/callouts/8.png +0 -0
- data/doc/guides/source/images/icons/callouts/9.png +0 -0
- data/doc/guides/source/images/icons/caution.png +0 -0
- data/doc/guides/source/images/icons/example.png +0 -0
- data/doc/guides/source/images/icons/home.png +0 -0
- data/doc/guides/source/images/icons/important.png +0 -0
- data/doc/guides/source/images/icons/next.png +0 -0
- data/doc/guides/source/images/icons/note.png +0 -0
- data/doc/guides/source/images/icons/prev.png +0 -0
- data/doc/guides/source/images/icons/tip.png +0 -0
- data/doc/guides/source/images/icons/up.png +0 -0
- data/doc/guides/source/images/icons/warning.png +0 -0
- data/doc/guides/source/images/polymorphic.png +0 -0
- data/doc/guides/source/images/rails_logo_remix.gif +0 -0
- data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
- data/doc/guides/source/images/session_fixation.png +0 -0
- data/doc/guides/source/index.txt +0 -118
- data/doc/guides/source/layouts_and_rendering.txt +0 -982
- data/doc/guides/source/migrations/anatomy_of_a_migration.txt +0 -85
- data/doc/guides/source/migrations/changelog.txt +0 -5
- data/doc/guides/source/migrations/creating_a_migration.txt +0 -109
- data/doc/guides/source/migrations/foreign_keys.txt +0 -8
- data/doc/guides/source/migrations/index.txt +0 -22
- data/doc/guides/source/migrations/rakeing_around.txt +0 -111
- data/doc/guides/source/migrations/scheming.txt +0 -47
- data/doc/guides/source/migrations/using_models_in_migrations.txt +0 -46
- data/doc/guides/source/migrations/writing_a_migration.txt +0 -159
- data/doc/guides/source/routing_outside_in.txt +0 -986
- data/doc/guides/source/security.txt +0 -984
- data/doc/guides/source/stylesheets/base.css +0 -358
- data/doc/guides/source/stylesheets/forms.css +0 -35
- data/doc/guides/source/stylesheets/more.css +0 -82
- data/doc/guides/source/templates/guides.html.erb +0 -97
- data/doc/guides/source/templates/inline.css +0 -165
- data/doc/guides/source/testing_rails_applications.txt +0 -995
- data/environments/boot.rb +0 -109
- data/environments/development.rb +0 -17
- data/environments/environment.rb +0 -75
- data/environments/production.rb +0 -24
- data/environments/test.rb +0 -22
- data/fresh_rakefile +0 -10
- data/helpers/application.rb +0 -15
- data/helpers/application_helper.rb +0 -3
- data/helpers/performance_test.rb +0 -9
- data/helpers/test_helper.rb +0 -38
- data/html/404.html +0 -30
- data/html/422.html +0 -30
- data/html/500.html +0 -33
- data/html/favicon.ico +0 -0
- data/html/images/rails.png +0 -0
- data/html/index.html +0 -274
- data/html/javascripts/application.js +0 -2
- data/html/javascripts/controls.js +0 -963
- data/html/javascripts/dragdrop.js +0 -973
- data/html/javascripts/effects.js +0 -1128
- data/html/javascripts/prototype.js +0 -4320
- data/html/robots.txt +0 -5
- data/lib/code_statistics.rb +0 -107
- data/lib/commands.rb +0 -17
- data/lib/commands/about.rb +0 -3
- data/lib/commands/console.rb +0 -45
- data/lib/commands/dbconsole.rb +0 -67
- data/lib/commands/destroy.rb +0 -6
- data/lib/commands/generate.rb +0 -6
- data/lib/commands/ncgi/listener +0 -86
- data/lib/commands/ncgi/tracker +0 -69
- data/lib/commands/performance/benchmarker.rb +0 -24
- data/lib/commands/performance/profiler.rb +0 -50
- data/lib/commands/performance/request.rb +0 -6
- data/lib/commands/plugin.rb +0 -967
- data/lib/commands/process/inspector.rb +0 -68
- data/lib/commands/process/reaper.rb +0 -149
- data/lib/commands/process/spawner.rb +0 -219
- data/lib/commands/process/spinner.rb +0 -57
- data/lib/commands/runner.rb +0 -48
- data/lib/commands/server.rb +0 -49
- data/lib/commands/servers/base.rb +0 -31
- data/lib/commands/servers/lighttpd.rb +0 -94
- data/lib/commands/servers/mongrel.rb +0 -69
- data/lib/commands/servers/new_mongrel.rb +0 -16
- data/lib/commands/servers/thin.rb +0 -25
- data/lib/commands/servers/webrick.rb +0 -66
- data/lib/commands/update.rb +0 -4
- data/lib/console_app.rb +0 -30
- data/lib/console_sandbox.rb +0 -6
- data/lib/console_with_helpers.rb +0 -26
- data/lib/dispatcher.rb +0 -24
- data/lib/fcgi_handler.rb +0 -237
- data/lib/initializer.rb +0 -1038
- data/lib/performance_test_help.rb +0 -5
- data/lib/rails/gem_builder.rb +0 -21
- data/lib/rails/gem_dependency.rb +0 -251
- data/lib/rails/mongrel_server/commands.rb +0 -342
- data/lib/rails/mongrel_server/handler.rb +0 -55
- data/lib/rails/plugin.rb +0 -124
- data/lib/rails/plugin/loader.rb +0 -152
- data/lib/rails/plugin/locator.rb +0 -100
- data/lib/rails/rack.rb +0 -6
- data/lib/rails/rack/logger.rb +0 -28
- data/lib/rails/rack/static.rb +0 -35
- data/lib/rails/vendor_gem_source_index.rb +0 -140
- data/lib/rails/version.rb +0 -9
- data/lib/rails_generator.rb +0 -43
- data/lib/rails_generator/base.rb +0 -263
- data/lib/rails_generator/commands.rb +0 -616
- data/lib/rails_generator/generated_attribute.rb +0 -46
- data/lib/rails_generator/generators/applications/app/USAGE +0 -9
- data/lib/rails_generator/generators/applications/app/app_generator.rb +0 -184
- data/lib/rails_generator/generators/components/controller/USAGE +0 -29
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +0 -37
- data/lib/rails_generator/generators/components/controller/templates/controller.rb +0 -7
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +0 -8
- data/lib/rails_generator/generators/components/controller/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/controller/templates/view.html.erb +0 -2
- data/lib/rails_generator/generators/components/integration_test/USAGE +0 -8
- data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +0 -16
- data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +0 -10
- data/lib/rails_generator/generators/components/mailer/USAGE +0 -16
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +0 -30
- data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -0
- data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +0 -15
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +0 -20
- data/lib/rails_generator/generators/components/mailer/templates/view.erb +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -0
- data/lib/rails_generator/generators/components/migration/USAGE +0 -29
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +0 -20
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +0 -11
- data/lib/rails_generator/generators/components/model/USAGE +0 -27
- data/lib/rails_generator/generators/components/model/model_generator.rb +0 -45
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +0 -19
- data/lib/rails_generator/generators/components/model/templates/migration.rb +0 -16
- data/lib/rails_generator/generators/components/model/templates/model.rb +0 -5
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/observer/USAGE +0 -13
- data/lib/rails_generator/generators/components/observer/observer_generator.rb +0 -16
- data/lib/rails_generator/generators/components/observer/templates/observer.rb +0 -2
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/performance_test/USAGE +0 -8
- data/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +0 -16
- data/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +0 -9
- data/lib/rails_generator/generators/components/plugin/USAGE +0 -25
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +0 -39
- data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +0 -20
- data/lib/rails_generator/generators/components/plugin/templates/README +0 -13
- data/lib/rails_generator/generators/components/plugin/templates/Rakefile +0 -23
- data/lib/rails_generator/generators/components/plugin/templates/USAGE +0 -8
- data/lib/rails_generator/generators/components/plugin/templates/generator.rb +0 -8
- data/lib/rails_generator/generators/components/plugin/templates/init.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/install.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +0 -4
- data/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +0 -3
- data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/resource/USAGE +0 -23
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +0 -74
- data/lib/rails_generator/generators/components/resource/templates/controller.rb +0 -2
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +0 -8
- data/lib/rails_generator/generators/components/resource/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold/USAGE +0 -29
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -100
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +0 -85
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +0 -45
- data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +0 -17
- data/lib/rails_generator/generators/components/scaffold/templates/style.css +0 -54
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +0 -18
- data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +0 -24
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +0 -17
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +0 -10
- data/lib/rails_generator/generators/components/session_migration/USAGE +0 -10
- data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +0 -18
- data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +0 -16
- data/lib/rails_generator/lookup.rb +0 -249
- data/lib/rails_generator/manifest.rb +0 -53
- data/lib/rails_generator/options.rb +0 -150
- data/lib/rails_generator/scripts.rb +0 -89
- data/lib/rails_generator/scripts/destroy.rb +0 -29
- data/lib/rails_generator/scripts/generate.rb +0 -7
- data/lib/rails_generator/scripts/update.rb +0 -12
- data/lib/rails_generator/secret_key_generator.rb +0 -22
- data/lib/rails_generator/simple_logger.rb +0 -46
- data/lib/rails_generator/spec.rb +0 -44
- data/lib/railties_path.rb +0 -1
- data/lib/ruby_version_check.rb +0 -17
- data/lib/rubyprof_ext.rb +0 -35
- data/lib/source_annotation_extractor.rb +0 -102
- data/lib/tasks/annotations.rake +0 -20
- data/lib/tasks/databases.rake +0 -416
- data/lib/tasks/documentation.rake +0 -95
- data/lib/tasks/framework.rake +0 -118
- data/lib/tasks/gems.rake +0 -80
- data/lib/tasks/log.rake +0 -9
- data/lib/tasks/misc.rake +0 -56
- data/lib/tasks/rails.rb +0 -8
- data/lib/tasks/routes.rake +0 -17
- data/lib/tasks/statistics.rake +0 -18
- data/lib/tasks/testing.rake +0 -139
- data/lib/tasks/tmp.rake +0 -37
- data/lib/test_help.rb +0 -27
- data/lib/webrick_server.rb +0 -156
@@ -1,242 +0,0 @@
|
|
1
|
-
Benchmarking and Profiling Rails
|
2
|
-
================================
|
3
|
-
|
4
|
-
This guide covers the benchmarking and profiling tactics/tools of Rails and Ruby in general. By referring to this guide, you will be able to:
|
5
|
-
|
6
|
-
* Understand the various types of benchmarking and profiling metrics
|
7
|
-
* Generate performance/benchmarking tests
|
8
|
-
* Use GC patched Ruby binary to measure memory usage and object allocation
|
9
|
-
* Understand the information provided by Rails inside the log files
|
10
|
-
* Learn about various tools facilitating benchmarking and profiling
|
11
|
-
|
12
|
-
== Why Benchmark and Profile ?
|
13
|
-
|
14
|
-
Benchmarking and Profiling is an integral part of the development cycle. It is very important that you don't make your end users wait for too long before the page is completely loaded. Ensuring a plesant browsing experience to the end users and cutting cost of unnecessary hardwares is important for any web application.
|
15
|
-
|
16
|
-
=== What is the difference between benchmarking and profiling ? ===
|
17
|
-
|
18
|
-
Benchmarking is the process of finding out if a piece of code is slow or not. Whereas profiling is the process of finding out what exactly is slowing down that piece of code.
|
19
|
-
|
20
|
-
== Using and understanding the log files ==
|
21
|
-
|
22
|
-
Rails logs files containt basic but very useful information about the time taken to serve every request. A typical log entry looks something like :
|
23
|
-
|
24
|
-
[source, ruby]
|
25
|
-
----------------------------------------------------------------------------
|
26
|
-
Processing ItemsController#index (for 127.0.0.1 at 2008-10-17 00:08:18) [GET]
|
27
|
-
Session ID: BAh7BiIKZmxhc2hJQzonQWN0aHsABjoKQHVzZWR7AA==--83cff4fe0a897074a65335
|
28
|
-
Parameters: {"action"=>"index", "controller"=>"items"}
|
29
|
-
Rendering template within layouts/items
|
30
|
-
Rendering items/index
|
31
|
-
Completed in 5ms (View: 2, DB: 0) | 200 OK [http://localhost/items]
|
32
|
-
----------------------------------------------------------------------------
|
33
|
-
|
34
|
-
For this section, we're only interested in the last line from that log entry:
|
35
|
-
|
36
|
-
[source, ruby]
|
37
|
-
----------------------------------------------------------------------------
|
38
|
-
Completed in 5ms (View: 2, DB: 0) | 200 OK [http://localhost/items]
|
39
|
-
----------------------------------------------------------------------------
|
40
|
-
|
41
|
-
This data is fairly straight forward to understand. Rails uses millisecond(ms) as the metric to measures the time taken. The complete request spent 5 ms inside Rails, out of which 2 ms were spent rendering views and none was spent communication with the database. It's safe to assume that the remaining 3 ms were spent inside the controller.
|
42
|
-
|
43
|
-
== Helper methods ==
|
44
|
-
|
45
|
-
Rails provides various helper methods inside Active Record, Action Controller and Action View to measure the time taken by a specific code. The method is called +benchmark()+ in all three components.
|
46
|
-
|
47
|
-
[source, ruby]
|
48
|
-
----------------------------------------------------------------------------
|
49
|
-
Project.benchmark("Creating project") do
|
50
|
-
project = Project.create("name" => "stuff")
|
51
|
-
project.create_manager("name" => "David")
|
52
|
-
project.milestones << Milestone.find(:all)
|
53
|
-
end
|
54
|
-
----------------------------------------------------------------------------
|
55
|
-
|
56
|
-
The above code benchmarks the multiple statments enclosed inside +Project.benchmark("Creating project") do..end+ block and prints the results inside log files. The statement inside log files will look like:
|
57
|
-
|
58
|
-
[source, ruby]
|
59
|
-
----------------------------------------------------------------------------
|
60
|
-
Creating projectem (185.3ms)
|
61
|
-
----------------------------------------------------------------------------
|
62
|
-
|
63
|
-
Please refer to http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M001336[API docs] for optional options to +benchmark()+
|
64
|
-
|
65
|
-
Similarly, you could use this helper method inside http://api.rubyonrails.com/classes/ActionController/Benchmarking/ClassMethods.html#M000715[controllers] ( Note that it's a class method here ):
|
66
|
-
|
67
|
-
[source, ruby]
|
68
|
-
----------------------------------------------------------------------------
|
69
|
-
def process_projects
|
70
|
-
self.class.benchmark("Processing projects") do
|
71
|
-
Project.process(params[:project_ids])
|
72
|
-
Project.update_cached_projects
|
73
|
-
end
|
74
|
-
end
|
75
|
-
----------------------------------------------------------------------------
|
76
|
-
|
77
|
-
and http://api.rubyonrails.com/classes/ActionController/Benchmarking/ClassMethods.html#M000715[views]:
|
78
|
-
|
79
|
-
[source, ruby]
|
80
|
-
----------------------------------------------------------------------------
|
81
|
-
<% benchmark("Showing projects partial") do %>
|
82
|
-
<%= render :partial => @projects %>
|
83
|
-
<% end %>
|
84
|
-
----------------------------------------------------------------------------
|
85
|
-
|
86
|
-
== Performance Test Cases ==
|
87
|
-
|
88
|
-
Rails provides a very easy to write performance test cases, which look just like the regular integration tests.
|
89
|
-
|
90
|
-
If you have a look at +test/performance/browsing_test.rb+ in a newly created Rails application:
|
91
|
-
|
92
|
-
[source, ruby]
|
93
|
-
----------------------------------------------------------------------------
|
94
|
-
require 'test_helper'
|
95
|
-
require 'performance_test_help'
|
96
|
-
|
97
|
-
# Profiling results for each test method are written to tmp/performance.
|
98
|
-
class BrowsingTest < ActionController::PerformanceTest
|
99
|
-
def test_homepage
|
100
|
-
get '/'
|
101
|
-
end
|
102
|
-
end
|
103
|
-
----------------------------------------------------------------------------
|
104
|
-
|
105
|
-
This is an automatically generated example performance test file, for testing performance of homepage('/') of the application.
|
106
|
-
|
107
|
-
=== Modes ===
|
108
|
-
|
109
|
-
==== Benchmarking ====
|
110
|
-
==== Profiling ====
|
111
|
-
|
112
|
-
=== Metrics ===
|
113
|
-
|
114
|
-
==== Process Time ====
|
115
|
-
|
116
|
-
CPU Cycles.
|
117
|
-
|
118
|
-
==== Memory ====
|
119
|
-
|
120
|
-
Memory taken.
|
121
|
-
|
122
|
-
==== Objects ====
|
123
|
-
|
124
|
-
Objects allocated.
|
125
|
-
|
126
|
-
==== GC Runs ====
|
127
|
-
|
128
|
-
Number of times the Ruby GC was run.
|
129
|
-
|
130
|
-
==== GC Time ====
|
131
|
-
|
132
|
-
Time spent running the Ruby GC.
|
133
|
-
|
134
|
-
=== Preparing Ruby and Ruby-prof ===
|
135
|
-
|
136
|
-
Before we go ahead, Rails performance testing requires you to build a special Ruby binary with some super powers - GC patch for measuring GC Runs/Time. This process is very straight forward. If you've never compiled a Ruby binary before, you can follow the following steps to build a ruby binary inside your home directory:
|
137
|
-
|
138
|
-
==== Compile ====
|
139
|
-
|
140
|
-
[source, shell]
|
141
|
-
----------------------------------------------------------------------------
|
142
|
-
[lifo@null ~]$ mkdir rubygc
|
143
|
-
[lifo@null ~]$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz
|
144
|
-
[lifo@null ~]$ tar -xzvf ruby-1.8.6-p111.tar.gz
|
145
|
-
[lifo@null ~]$ cd ruby-1.8.6-p111
|
146
|
-
[lifo@null ruby-1.8.6-p111]$ curl http://rubyforge.org/tracker/download.php/1814/7062/17676/3291/ruby186gc.patch | patch -p0
|
147
|
-
[lifo@null ruby-1.8.6-p111]$ ./configure --prefix=/Users/lifo/rubygc
|
148
|
-
[lifo@null ruby-1.8.6-p111]$ make && make install
|
149
|
-
----------------------------------------------------------------------------
|
150
|
-
|
151
|
-
==== Prepare aliases ====
|
152
|
-
|
153
|
-
Add the following lines in your ~/.profile for convenience:
|
154
|
-
|
155
|
-
----------------------------------------------------------------------------
|
156
|
-
alias gcruby='/Users/lifo/rubygc/bin/ruby'
|
157
|
-
alias gcrake='/Users/lifo/rubygc/bin/rake'
|
158
|
-
alias gcgem='/Users/lifo/rubygc/bin/gem'
|
159
|
-
alias gcirb='/Users/lifo/rubygc/bin/irb'
|
160
|
-
alias gcrails='/Users/lifo/rubygc/bin/rails'
|
161
|
-
----------------------------------------------------------------------------
|
162
|
-
|
163
|
-
==== Install rubygems and some basic gems ====
|
164
|
-
|
165
|
-
----------------------------------------------------------------------------
|
166
|
-
[lifo@null ~]$ wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
|
167
|
-
[lifo@null ~]$ tar -xzvf rubygems-1.2.0.tgz
|
168
|
-
[lifo@null ~]$ cd rubygems-1.2.0
|
169
|
-
[lifo@null rubygems-1.2.0]$ gcruby setup.rb
|
170
|
-
[lifo@null rubygems-1.2.0]$ cd ~
|
171
|
-
[lifo@null ~]$ gcgem install rake
|
172
|
-
[lifo@null ~]$ gcgem install rails
|
173
|
-
----------------------------------------------------------------------------
|
174
|
-
|
175
|
-
==== Install MySQL gem ====
|
176
|
-
|
177
|
-
----------------------------------------------------------------------------
|
178
|
-
[lifo@null ~]$ gcgem install mysql
|
179
|
-
----------------------------------------------------------------------------
|
180
|
-
|
181
|
-
If this fails, you can try to install it manually:
|
182
|
-
|
183
|
-
----------------------------------------------------------------------------
|
184
|
-
[lifo@null ~]$ cd /Users/lifo/rubygc/lib/ruby/gems/1.8/gems/mysql-2.7/
|
185
|
-
[lifo@null mysql-2.7]$ gcruby extconf.rb --with-mysql-config
|
186
|
-
[lifo@null mysql-2.7]$ make && make install
|
187
|
-
----------------------------------------------------------------------------
|
188
|
-
|
189
|
-
=== Installing Jeremy Kemper's ruby-prof ===
|
190
|
-
|
191
|
-
We also need to install Jeremy's ruby-prof gem using our newly built ruby:
|
192
|
-
|
193
|
-
[source, shell]
|
194
|
-
----------------------------------------------------------------------------
|
195
|
-
[lifo@null ~]$ git clone git://github.com/jeremy/ruby-prof.git
|
196
|
-
[lifo@null ~]$ cd ruby-prof/
|
197
|
-
[lifo@null ruby-prof (master)]$ gcrake gem
|
198
|
-
[lifo@null ruby-prof (master)]$ gcgem install pkg/ruby-prof-0.6.1.gem
|
199
|
-
----------------------------------------------------------------------------
|
200
|
-
|
201
|
-
=== Generating performance test ===
|
202
|
-
|
203
|
-
Rails provides a simple generator for creating new performance tests:
|
204
|
-
|
205
|
-
[source, shell]
|
206
|
-
----------------------------------------------------------------------------
|
207
|
-
[lifo@null application (master)]$ script/generate performance_test homepage
|
208
|
-
----------------------------------------------------------------------------
|
209
|
-
|
210
|
-
This will generate +test/performance/homepage_test.rb+:
|
211
|
-
|
212
|
-
[source, ruby]
|
213
|
-
----------------------------------------------------------------------------
|
214
|
-
require 'test_helper'
|
215
|
-
require 'performance_test_help'
|
216
|
-
|
217
|
-
class HomepageTest < ActionController::PerformanceTest
|
218
|
-
# Replace this with your real tests.
|
219
|
-
def test_homepage
|
220
|
-
get '/'
|
221
|
-
end
|
222
|
-
end
|
223
|
-
----------------------------------------------------------------------------
|
224
|
-
|
225
|
-
Which you can modify to suit your needs.
|
226
|
-
|
227
|
-
=== Running tests ===
|
228
|
-
|
229
|
-
include::rubyprof.txt[]
|
230
|
-
|
231
|
-
include::digging_deeper.txt[]
|
232
|
-
|
233
|
-
include::gameplan.txt[]
|
234
|
-
|
235
|
-
include::appendix.txt[]
|
236
|
-
|
237
|
-
== Changelog ==
|
238
|
-
|
239
|
-
http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/4[Lighthouse ticket]
|
240
|
-
|
241
|
-
* October 17, 2008: First revision by Pratik
|
242
|
-
* September 6, 2008: Initial version by Matthew Bergman <MzbPhoto@gmail.com>
|
@@ -1,179 +0,0 @@
|
|
1
|
-
== Understanding Performance Tests Outputs ==
|
2
|
-
|
3
|
-
=== Our First Performance Test ===
|
4
|
-
|
5
|
-
So how do we profile a request.
|
6
|
-
|
7
|
-
One of the things that is important to us is how long it takes to render the home page - so let's make a request to the home page. Once the request is complete, the results will be outputted in the terminal.
|
8
|
-
|
9
|
-
In the terminal run
|
10
|
-
|
11
|
-
[source, ruby]
|
12
|
-
----------------------------------------------------------------------------
|
13
|
-
[User profiling_tester]$ gcruby tests/performance/homepage.rb
|
14
|
-
----------------------------------------------------------------------------
|
15
|
-
|
16
|
-
After the tests runs for a few seconds you should see something like this.
|
17
|
-
|
18
|
-
----------------------------------------------------------------------------
|
19
|
-
HomepageTest#test_homepage (19 ms warmup)
|
20
|
-
process_time: 26 ms
|
21
|
-
memory: 298.79 KB
|
22
|
-
objects: 1917
|
23
|
-
|
24
|
-
Finished in 2.207428 seconds.
|
25
|
-
----------------------------------------------------------------------------
|
26
|
-
|
27
|
-
Simple but efficient.
|
28
|
-
|
29
|
-
* Process Time refers to amount of time necessary to complete the action.
|
30
|
-
* memory is the amount of information loaded into memory
|
31
|
-
* object ??? #TODO find a good definition. Is it the amount of objects put into a ruby heap for this process?
|
32
|
-
|
33
|
-
In addition we also gain three types of itemized log files for each of these outputs. They can be found in your tmp directory of your application.
|
34
|
-
|
35
|
-
*The Three types are*
|
36
|
-
|
37
|
-
* Flat File - A simple text file with the data laid out in a grid
|
38
|
-
* Graphical File - A html colored coded version of the simple text file with hyperlinks between the various methods. Most useful is the bolding of the main processes for each portion of the action.
|
39
|
-
* Tree File - A file output that can be use in conjunction with KCachegrind to visualize the process
|
40
|
-
|
41
|
-
NOTE: KCachegrind is Linux only. For Mac this means you have to do a full KDE install to have it working in your OS. Which is over 3 gigs in size. For windows there is clone called wincachegrind but it is no longer actively being developed.
|
42
|
-
|
43
|
-
Below are examples for Flat Files and Graphical Files
|
44
|
-
|
45
|
-
=== Flat Files ===
|
46
|
-
|
47
|
-
.Flat File Output Processing Time
|
48
|
-
============================================================================
|
49
|
-
Thread ID: 2279160
|
50
|
-
Total: 0.026097
|
51
|
-
|
52
|
-
%self total self wait child calls name
|
53
|
-
6.41 0.06 0.04 0.00 0.02 571 Kernel#===
|
54
|
-
3.17 0.00 0.00 0.00 0.00 172 Hash#[]
|
55
|
-
2.42 0.00 0.00 0.00 0.00 13 MonitorMixin#mon_exit
|
56
|
-
2.05 0.00 0.00 0.00 0.00 15 Array#each
|
57
|
-
1.56 0.00 0.00 0.00 0.00 6 Logger#add
|
58
|
-
1.55 0.00 0.00 0.00 0.00 13 MonitorMixin#mon_enter
|
59
|
-
1.36 0.03 0.00 0.00 0.03 1 ActionController::Integration::Session#process
|
60
|
-
1.31 0.00 0.00 0.00 0.00 13 MonitorMixin#mon_release
|
61
|
-
1.15 0.00 0.00 0.00 0.00 8 MonitorMixin#synchronize-1
|
62
|
-
1.09 0.00 0.00 0.00 0.00 23 Class#new
|
63
|
-
1.03 0.01 0.00 0.00 0.01 5 MonitorMixin#synchronize
|
64
|
-
0.89 0.00 0.00 0.00 0.00 74 Hash#default
|
65
|
-
0.89 0.00 0.00 0.00 0.00 6 Hodel3000CompliantLogger#format_message
|
66
|
-
0.80 0.00 0.00 0.00 0.00 9 c
|
67
|
-
0.80 0.00 0.00 0.00 0.00 11 ActiveRecord::ConnectionAdapters::ConnectionHandler#retrieve_connection_pool
|
68
|
-
0.79 0.01 0.00 0.00 0.01 1 ActionController::Benchmarking#perform_action_without_rescue
|
69
|
-
0.18 0.00 0.00 0.00 0.00 17 <Class::Object>#allocate
|
70
|
-
============================================================================
|
71
|
-
|
72
|
-
So what do these columns tell us:
|
73
|
-
|
74
|
-
* %self - The percentage of time spent processing the method. This is derived from self_time/total_time
|
75
|
-
* total - The time spent in this method and its children.
|
76
|
-
* self - The time spent in this method.
|
77
|
-
* wait - Time processed was queued
|
78
|
-
* child - The time spent in this method's children.
|
79
|
-
* calls - The number of times this method was called.
|
80
|
-
* name - The name of the method.
|
81
|
-
|
82
|
-
Name can be displayed three seperate ways:
|
83
|
-
* #toplevel - The root method that calls all other methods
|
84
|
-
* MyObject#method - Example Hash#each, The class Hash is calling the method each
|
85
|
-
* <Object:MyObject>#test - The <> characters indicate a singleton method on a singleton class. Example <Class::Object>#allocate
|
86
|
-
|
87
|
-
Methods are sorted based on %self. Hence the ones taking the most time and resources will be at the top.
|
88
|
-
|
89
|
-
So for Array#each which is calling each on the class array. We find that it processing time is 2% of the total and was called 15 times. The rest of the information is 0.00 because the process is so fast it isn't recording times less then 100 ms.
|
90
|
-
|
91
|
-
|
92
|
-
.Flat File Memory Output
|
93
|
-
============================================================================
|
94
|
-
Thread ID: 2279160
|
95
|
-
Total: 509.724609
|
96
|
-
|
97
|
-
%self total self wait child calls name
|
98
|
-
4.62 23.57 23.57 0.00 0.00 34 String#split
|
99
|
-
3.95 57.66 20.13 0.00 37.53 3 <Module::YAML>#quick_emit
|
100
|
-
2.82 23.70 14.35 0.00 9.34 2 <Module::YAML>#quick_emit-1
|
101
|
-
1.37 35.87 6.96 0.00 28.91 1 ActionView::Helpers::FormTagHelper#form_tag
|
102
|
-
1.35 7.69 6.88 0.00 0.81 1 ActionController::HttpAuthentication::Basic::ControllerMethods#authenticate_with_http_basic
|
103
|
-
1.06 6.09 5.42 0.00 0.67 90 String#gsub
|
104
|
-
1.01 5.13 5.13 0.00 0.00 27 Array#-
|
105
|
-
============================================================================
|
106
|
-
|
107
|
-
Very similar to the processing time format. The main difference here is that instead of calculating time we are now concerned with the amount of KB put into memory *(or is it strictly into the heap) can I get clarification on this minor point?*
|
108
|
-
|
109
|
-
So for <Module::YAML>#quick_emit which is singleton method on the class YAML it uses 57.66 KB in total, 23.57 through its own actions, 6.69 from actions it calls itself and that it was called twice.
|
110
|
-
|
111
|
-
.Flat File Objects
|
112
|
-
============================================================================
|
113
|
-
Thread ID: 2279160
|
114
|
-
Total: 6537.000000
|
115
|
-
|
116
|
-
%self total self wait child calls name
|
117
|
-
15.16 1096.00 991.00 0.00 105.00 66 Hash#each
|
118
|
-
5.25 343.00 343.00 0.00 0.00 4 Mysql::Result#each_hash
|
119
|
-
4.74 2203.00 310.00 0.00 1893.00 42 Array#each
|
120
|
-
3.75 4529.00 245.00 0.00 4284.00 1 ActionView::Base::CompiledTemplates#_run_erb_47app47views47layouts47application46html46erb
|
121
|
-
2.00 136.00 131.00 0.00 5.00 90 String#gsub
|
122
|
-
1.73 113.00 113.00 0.00 0.00 34 String#split
|
123
|
-
1.44 111.00 94.00 0.00 17.00 31 Array#each-1
|
124
|
-
============================================================================
|
125
|
-
|
126
|
-
|
127
|
-
#TODO Find correct terminology for how to describe what this is exactly profiling as in are there really 2203 array objects or 2203 pointers to array objects?.
|
128
|
-
|
129
|
-
=== Graph Files ===
|
130
|
-
|
131
|
-
While the information gleamed from flat files is very useful we still don't know which processes each method is calling. We only know how many. This is not true for a graph file. Below is a text representation of a graph file. The actual graph file is an html entity and an example of which can be found link:examples/graph.html[Here]
|
132
|
-
|
133
|
-
#TODO (Handily the graph file has links both between it many processes and to the files that actually contain them for debugging.
|
134
|
-
)
|
135
|
-
|
136
|
-
.Graph File
|
137
|
-
============================================================================
|
138
|
-
Thread ID: 21277412
|
139
|
-
|
140
|
-
%total %self total self children calls Name
|
141
|
-
/____________________________________________________________________________/
|
142
|
-
100.00% 0.00% 8.77 0.00 8.77 1 #toplevel*
|
143
|
-
8.77 0.00 8.77 1/1 Object#run_primes
|
144
|
-
/____________________________________________________________________________/
|
145
|
-
8.77 0.00 8.77 1/1 #toplevel
|
146
|
-
100.00% 0.00% 8.77 0.00 8.77 1 Object#run_primes*
|
147
|
-
0.02 0.00 0.02 1/1 Object#make_random_array
|
148
|
-
2.09 0.00 2.09 1/1 Object#find_largest
|
149
|
-
6.66 0.00 6.66 1/1 Object#find_primes
|
150
|
-
/____________________________________________________________________________/
|
151
|
-
0.02 0.02 0.00 1/1 Object#make_random_array
|
152
|
-
0.18% 0.18% 0.02 0.02 0.00 1 Array#each_index
|
153
|
-
0.00 0.00 0.00 500/500 Kernel.rand
|
154
|
-
0.00 0.00 0.00 500/501 Array#[]=
|
155
|
-
/____________________________________________________________________________/
|
156
|
-
============================================================================
|
157
|
-
|
158
|
-
As you can see the calls have been separated into slices, no longer is the order determined by process time but instead from hierarchy. Each slice profiles a primary entry, with the primary entry's parents being shown above itself and it's children found below. A primary entry can be ascertained by it having values in the %total and %self columns. Here the main entry here have been bolded for connivence.
|
159
|
-
|
160
|
-
So if we look at the last slice. The primary entry would be Array#each_index. It takes 0.18% of the total process time and it is only called once. It is called from Object#make_random_array which is only called once. It's children are Kernal.rand which is called by it all 500 its times that it was call in this action and Arry#[]= which was called 500 times by Array#each_index and once by some other entry.
|
161
|
-
|
162
|
-
=== Tree Files ===
|
163
|
-
|
164
|
-
It's pointless trying to represent a tree file textually so here's a few pretty pictures of it's usefulness
|
165
|
-
|
166
|
-
.KCachegrind Graph
|
167
|
-
[caption="KCachegrind graph"]
|
168
|
-
image:images/kgraph.png[Graph created by KCachegrind]
|
169
|
-
|
170
|
-
.KCachegrind List
|
171
|
-
[caption="KCachegrind List"]
|
172
|
-
image:images/klist.png[List created by KCachegrind]
|
173
|
-
|
174
|
-
#TODO Add a bit more information to this.
|
175
|
-
|
176
|
-
== Getting to the Point of all of this ==
|
177
|
-
|
178
|
-
Now I know all of this is a bit dry and academic. But it's a very powerful tool when you know how to leverage it properly. Which we are going to take a look at in our next section
|
179
|
-
|
@@ -1,57 +0,0 @@
|
|
1
|
-
== A Lession In Statistics ==
|
2
|
-
|
3
|
-
#TODO COMPRESS DOWN INTO A PARAGRAPH AND A HALF
|
4
|
-
maybe I'll just combine with the methodology portion as an appendix.
|
5
|
-
|
6
|
-
Adapted from a blog Article by Zed Shaw. His rant is funnier but will take longer to read. <br /> http://www.zedshaw.com/rants/programmer_stats.html[Programmers Need To Learn Statistics Or I Will Kill Them All]
|
7
|
-
|
8
|
-
=== Why Learn Statistics ===
|
9
|
-
|
10
|
-
Statistics is a hard discipline. One can study it for years without fully grasping all the complexities. But its a necessary evil for coders of every level to at least know the basics. You can't optimize without it, and if you use it wrong, you'll just waste your time and the rest of your team's.
|
11
|
-
|
12
|
-
=== Power-of-Ten Syndrome ===
|
13
|
-
|
14
|
-
If you done any benchmarking you have probably heard
|
15
|
-
“All you need to do is run that test [insert power-of-ten] times and then do an average.”
|
16
|
-
|
17
|
-
For new developers this whole power of ten comes about because we need enough data to minimize the results being contaminated by outliers. If you loaded a page five times with three of those times being around 75ms and twice 250ms you have no way of knowing the real average processing time for you page. But if we take a 1000 times and 950 are 75ms and 50 are 250ms we have a much clearer picture of the situation.
|
18
|
-
|
19
|
-
But this still begs the question of how you determine that 1000 is the correct number of iterations to improve the power of the experiment? (Power in this context basically means the chance that your experiment is right.)
|
20
|
-
|
21
|
-
The first thing that needs to be determined is how you are performing the samplings? 1000 iterations run in a massive sequential row? A set of 10 runs with 100 each? The statistics are different depending on which you do, but the 10 runs of 100 each would be a better approach. This lets you compare sample means and figure out if your repeated runs have any bias. More simply put, this allows you to see if you have a many or few outliers that might be poisoning your averages.
|
22
|
-
|
23
|
-
Another consideration is if a 1000 transactions is enough to get the process into a steady state after the ramp-up period? If you are benchmarking a long running process that stabilizes only after a warm-up time you must take that into consideration.
|
24
|
-
|
25
|
-
Also remember getting an average is not an end goal in itself. In fact in some cases they tell you almost nothing.
|
26
|
-
|
27
|
-
=== Don't Just Use Averages! ===
|
28
|
-
|
29
|
-
One cannot simply say my website “[insert power-of-ten] requests per second”. This is due to it being an Average. Without some form of range or variance error analysis it's a useless number. Two averages can be the same, but hide massive differences in behavior. Without a standard deviation it’s not possible to figure out if the two might even be close.
|
30
|
-
|
31
|
-
Two averages can be the same say 30 requests a second and yet have a completely different standard deviation. Say the first sample has +-3 and the second is +-30
|
32
|
-
|
33
|
-
Stability is vastly different for these two samples If this were a web server performance run I’d say the second server has a major reliability problem. No, it’s not going to crash, but it’s performance response is so erratic that you’d never know how long a request would take. Even though the two servers perform the same on average, users will think the second one is slower because of how it seems to randomly perform.
|
34
|
-
|
35
|
-
Another big thing to take into consideration when benchmarking and profiling is Confounding
|
36
|
-
|
37
|
-
=== Confounding ===
|
38
|
-
|
39
|
-
The idea of confounding is pretty simple: If you want to measure something, then don’t measure anything else.
|
40
|
-
|
41
|
-
#TODO add more information in how to avoid confounding.
|
42
|
-
|
43
|
-
* Your testing system and your production system must be separate. You can't profile on the same system because you are using resources to run the test that your server should be using to serve the requests.
|
44
|
-
|
45
|
-
And one more thing.
|
46
|
-
|
47
|
-
=== Define what you are Measuring ===
|
48
|
-
|
49
|
-
Before you can measure something you really need to lay down a very concrete definition of what you’re measuring. You should also try to measure the simplest thing you can and try to avoid confounding.
|
50
|
-
|
51
|
-
The most important thing to determine though is how much data you can actually send to your application through it's pipe.
|
52
|
-
|
53
|
-
=== Back to Business ===
|
54
|
-
|
55
|
-
Now I know this was all a bit boring, but these fundamentals a necessary for understanding what we are actually doing here. Now onto the actual code and rails processes.
|
56
|
-
|
57
|
-
|