Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xijo/birth_control
Count active record instantiations and report them to the log
https://github.com/xijo/birth_control
Last synced: about 2 months ago
JSON representation
Count active record instantiations and report them to the log
- Host: GitHub
- URL: https://github.com/xijo/birth_control
- Owner: xijo
- License: wtfpl
- Created: 2013-11-16T11:18:49.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-11-19T10:44:10.000Z (about 11 years ago)
- Last Synced: 2024-04-24T13:36:34.371Z (8 months ago)
- Language: Ruby
- Size: 137 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# BirthControl
Count active record instantiations and report them to the log.
[![Build Status](https://secure.travis-ci.org/xijo/birth_control.png)](http://travis-ci.org/xijo/birth_control)
[![Coderwall Endorse](http://api.coderwall.com/xijo/endorsecount.png)](http://coderwall.com/xijo)
## Installation
Add this line to your application's Gemfile:
gem 'birth_control', groups: [:development]
And then execute:
$ bundle
After bundling you'll need to enable the logging by putting this line into your development environment:
BirthControl.enable = true
## Usage
Two new reports will be logged into your rails log:
1. The class instantiation report - count all active record objects by class and in total
2. Duplication report - reveals where active record objects were loaded more than once### Example reports:
This example show the result of a project detail page. You can see, that there were 5 project instantiations but always the same project. The first two may be necassary, but the later 3 could have been avoided.
*** [BirthControl] Class instantiation overview ***
5 Projects
20 ProjectPictures
2 Users
1 Countries
3 BlogPosts
30 Total*** [BirthControl] Duplicate instantiation detected ***
Project(42) - 5 times
1. app/controllers/projects_controller.rb:27:in `load_project_for_caching'
2. app/controllers/projects_controller.rb:13:in `show'
3. app/views/projects/_blog_post.html.slim:3:in `...'
4. app/views/projects/_blog_post.html.slim:3:in `...'
5. app/views/projects/_blog_post.html.slim:3:in `...'## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request## Changelog
**0.0.1** (*2013-11-16*)
* Initial import, basic reports