diff options
author | Zachary Scott <e@zzak.io> | 2014-05-26 14:15:33 -0700 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2014-05-26 14:15:33 -0700 |
commit | 5af6120ad17f07c2d217b55faab1bebc83be98a0 (patch) | |
tree | c1e9239e0dabb9c9d199f25c98fa87b3bb362ca6 /guides/source/contributing_to_ruby_on_rails.md | |
parent | 923e274313dda8c772922e859df681f3d050a30e (diff) | |
parent | 8b39eca5b7a708fb1864e139d06fa59d099ae340 (diff) | |
download | rails-5af6120ad17f07c2d217b55faab1bebc83be98a0.tar.gz rails-5af6120ad17f07c2d217b55faab1bebc83be98a0.tar.bz2 rails-5af6120ad17f07c2d217b55faab1bebc83be98a0.zip |
Merge pull request #15347 from JuanitoFatas/benchmark-in-contributing-to-ror
[ci skip] Add benchmark your code section to contributing to ruby on rails guide.
Diffstat (limited to 'guides/source/contributing_to_ruby_on_rails.md')
-rw-r--r-- | guides/source/contributing_to_ruby_on_rails.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index d3a96daf7b..133ef58fd6 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -215,6 +215,36 @@ Rails follows a simple set of coding style conventions: The above are guidelines - please use your best judgment in using them. +### Benchmark Your Code + +If your change has an impact on the performance of Rails, please use the +[benchmark-ips](https://github.com/evanphx/benchmark-ips) gem to provide +benchmark results for comparison. + +Here's an example of using benchmark-ips: + +```ruby +require 'benchmark/ips' + +Benchmark.ips do |x| + x.report('addition') { 1 + 2 } + x.report('addition with send') { 1.send(:+, 2) } +end +``` + +This will generate a report with the following information: + +``` +Calculating ------------------------------------- + addition 69114 i/100ms + addition with send 64062 i/100ms +------------------------------------------------- + addition 5307644.4 (±3.5%) i/s - 26539776 in 5.007219s + addition with send 3702897.9 (±3.5%) i/s - 18513918 in 5.006723s +``` + +Please see the benchmark/ips [README](https://github.com/evanphx/benchmark-ips/blob/master/README.md) for more information. + ### Running Tests It is not customary in Rails to run the full test suite before pushing |