diff options
author | Robert Speicher <robert@gitlab.com> | 2017-01-27 20:03:09 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-01-27 20:03:09 +0000 |
commit | 2b78774aad8035e2c83b85999b7d8ca80e108455 (patch) | |
tree | 2bf1066344de89c1b651cee875f24709211a0707 /doc | |
parent | 437722be388385aba95f47c63334ef496ff2cfaa (diff) | |
parent | f83b8bd42c2a82b3ef9a8d93621b3955f0a8d0ca (diff) | |
download | gitlab-ce-2b78774aad8035e2c83b85999b7d8ca80e108455.tar.gz |
Merge branch '23034-enable-rspec-profiling' into 'master'
Add rspec_profiling to the rspec environment
Closes #23034
See merge request !7854
Diffstat (limited to 'doc')
-rw-r--r-- | doc/development/performance.md | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/doc/development/performance.md b/doc/development/performance.md index f936a49a2aa..c1f129e576c 100644 --- a/doc/development/performance.md +++ b/doc/development/performance.md @@ -211,6 +211,41 @@ suite first. See the [StackProf documentation](https://github.com/tmm1/stackprof/blob/master/README.md) for details. +## RSpec profiling + +GitLab's development environment also includes the +[rspec_profiling](https://github.com/foraker/rspec_profiling) gem, which is used +to collect data on spec execution times. This is useful for analyzing the +performance of the test suite itself, or seeing how the performance of a spec +may have changed over time. + +To activate profiling in your local environment, run the following: + +``` +$ export RSPEC_PROFILING=yes +$ rake rspec_profiling:install +``` + +This creates an SQLite3 database in `tmp/rspec_profiling`, into which statistics +are saved every time you run specs with the `RSPEC_PROFILING` environment +variable set. + +Ad-hoc investigation of the collected results can be performed in an interactive +shell: + +``` +$ rake rspec_profiling:console +irb(main):001:0> results.count +=> 231 +irb(main):002:0> results.last.attributes.keys +=> ["id", "commit", "date", "file", "line_number", "description", "time", "status", "exception", "query_count", "query_time", "request_count", "request_time", "created_at", "updated_at"] +irb(main):003:0> results.where(status: "passed").average(:time).to_s +=> "0.211340155844156" +``` +These results can also be placed into a PostgreSQL database by setting the +`RSPEC_PROFILING_POSTGRES_URL` variable. This is used to profile the test suite +when running in the CI environment. + ## Importance of Changes When working on performance improvements, it's important to always ask yourself |