summaryrefslogtreecommitdiff
path: root/doc/development
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-01-26 21:31:43 +0000
committerNick Thomas <nick@gitlab.com>2017-01-27 12:41:16 +0000
commitf83b8bd42c2a82b3ef9a8d93621b3955f0a8d0ca (patch)
tree50f6d5128a2941f019e6e19cee47efe8d3ebce9b /doc/development
parent9d7999242db6ab641df1351bae7cfd5766cfeaa3 (diff)
downloadgitlab-ce-f83b8bd42c2a82b3ef9a8d93621b3955f0a8d0ca.tar.gz
Add the rspec_profiling gem and documentation to the GitLab development environment23034-enable-rspec-profiling
Diffstat (limited to 'doc/development')
-rw-r--r--doc/development/performance.md35
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