Skip to content

Commit

Permalink
Finishing off post - yay!
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRogers0 committed Mar 28, 2015
1 parent a1beb73 commit 189aab4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 44 deletions.
3 changes: 0 additions & 3 deletions Gemfile
Expand Up @@ -4,9 +4,6 @@ gem 'jekyll'
gem 'jekyll-sass'
gem 'rdiscount'

# Work with Pow
gem 'rack-jekyll'

# Deploy to S3
gem 's3_website'

Expand Down
45 changes: 20 additions & 25 deletions Gemfile.lock
Expand Up @@ -11,20 +11,20 @@ GEM
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.8.0)
coffee-script-source (1.9.1)
colorator (0.1)
colored (1.2)
configure-s3-website (1.6.0)
configure-s3-website (1.7.1)
deep_merge (= 1.0.0)
css_press (0.3.2)
csspool-st (= 3.1.2)
json
csspool-st (3.1.2)
deep_merge (1.0.0)
dotenv (1.0.2)
execjs (2.2.2)
execjs (2.4.0)
fast-stemmer (1.0.2)
ffi (1.9.6)
ffi (1.9.8)
hitimes (1.2.2)
html_press (0.8.2)
htmlentities
Expand All @@ -48,7 +48,7 @@ GEM
toml (~> 0.1.0)
jekyll-coffeescript (1.0.1)
coffee-script (~> 2.2)
jekyll-gist (1.1.0)
jekyll-gist (1.2.1)
jekyll-paginate (1.1.0)
jekyll-press (0.2.1)
html_press (>= 0.8.2)
Expand All @@ -61,13 +61,13 @@ GEM
sass (>= 3.0.0)
jekyll-sass-converter (1.3.0)
sass (~> 3.2)
jekyll-watch (1.2.0)
jekyll-watch (1.2.1)
listen (~> 2.7)
json (1.8.2)
kramdown (1.5.0)
liquid (2.6.1)
listen (2.8.5)
celluloid (>= 0.15.2)
kramdown (1.6.0)
liquid (2.6.2)
listen (2.10.0)
celluloid (~> 0.16.0)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
mercenary (0.3.5)
Expand All @@ -79,39 +79,35 @@ GEM
autoprefixer-rails (~> 2.2)
jekyll (~> 2.0)
octopress-hooks (~> 2.0)
octopress-hooks (2.3.2)
octopress-hooks (2.6.0)
jekyll (~> 2.0)
parslet (1.5.0)
blankslate (~> 2.0)
posix-spawn (0.3.9)
pygments.rb (0.6.0)
posix-spawn (0.3.10)
pygments.rb (0.6.3)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.6.0)
rack-jekyll (0.3.5)
jekyll
rack
yajl-ruby (~> 1.2.0)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rdiscount (2.1.7.1)
rdiscount (2.1.8)
redcarpet (3.2.2)
s3_website (2.7.3)
s3_website (2.8.4)
colored (= 1.2)
configure-s3-website (= 1.6.0)
configure-s3-website (= 1.7.1)
dotenv (~> 1.0)
thor (~> 0.18)
safe_yaml (1.0.4)
sass (3.4.9)
sass (3.4.13)
thor (0.19.1)
timers (4.0.1)
hitimes
toml (0.1.2)
parslet (~> 1.5.0)
uglifier (2.7.0)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
yajl-ruby (1.1.0)
yajl-ruby (1.2.1)

PLATFORMS
ruby
Expand All @@ -121,6 +117,5 @@ DEPENDENCIES
jekyll-press
jekyll-sass
octopress-autoprefixer
rack-jekyll
rdiscount
s3_website
2 changes: 1 addition & 1 deletion _config.yml
Expand Up @@ -11,7 +11,7 @@ cdn_uri: ''
name: Mike Rogers
highlighter: true

production_url : https://mikerogers.io
production_url : http://mikerogers.io

env: production

Expand Down
Expand Up @@ -17,36 +17,37 @@ This got me thinking that it was crazy to not have been at least monitoring the

I went looking for something similar to [simplecov](https://github.com/colszowka/simplecov), but for memory. Unfortunately I couldn't find anything that fitted my needs out of the box.

However did I find [Oink](https://github.com/noahd1/oink), which creates a log of memory usage and then parses that log to generate a report. This was a big part of what I needed, so I decided I'll cobble something together to get started.
However I did find [Oink](https://github.com/noahd1/oink), a gem that creates a log of memory usage and then parses that log to generate a report. This handled a a big part of what I needed, so I decided I'll cobble the rest together and see where I end up.

### Setting up Oink

I only wanted Oink to run while I was running my test suite, so I set it up to only log memory while I was running my test suite. I done this by setting up an an initializer `config/initializers/oink.rb` that'll turn on Oink while in test mode.
I set up Oink to only log memory while I was running my test suite. I done this by setting up an an initializer ( `config/initializers/oink.rb` ).

{% gist 1da6a53cd0d626dbde5f oink.rb %}

Next I only wanted the Oink results from the last run of the test suite, so before each test I cleared all the logs in the `spec/rails_helper.rb` file.
Next I only wanted the Oink results from the last run of the test suite, so before each test I cleared all the logs via the `spec/rails_helper.rb` file.

Then once the tests had finished running, I called the terminal command from Rails with a low threshold, this returned the memory usage of each action.

{% gist 1da6a53cd0d626dbde5f rails_helper.rb %}

Once the tests had finished running, I called the terminal command from Rails with a low threshold, this returned the memory usage of each action.

### The output

I ran the test suite and this was the output:
This is the output I had after running my test suite.

{% gist 1da6a53cd0d626dbde5f example_output.txt %}

Pretty handy right?

## How I've been using this

The way I've been keeping an eye on memory usage with this setup is to compare the memory usage change between my master branch, and the feature branch before merging.
The way I've been keeping an eye on memory usage with this setup is a little crude, but I've been comparing the memory usage change between my master branch and the feature branch before merging.

So far it's been pretty handy to help me catch a few times where I implemented a Gem incorrectly and it also helped me track down a few of the more memory loving bits of code.
So far it has been pretty handy to help me catch a few times where I implemented a Gem poorly, furthermore it also helped me track down a few of the more memory loving bits of code.

## Going forward

This setup isn't great (I cobbled it together in an hour trying to find a memory leak), but I think trying to spot memory bloat/leaks before code gets into production is important.

What I'd like to do is build this as a Gem, where I can simply declare a maximum amount of memory the app is allowed to use during an acceptance test, and if the test goes over that amount the test should fail. If you think that sounds like a good idea, please [@me on twitter](https://twitter.com/MikeRogers0) and I'll try to get something organised.
What I'd like to do is build this as a Gem, where I can simply declare a maximum amount of memory the app is allowed to use during an acceptance test, and if the test goes over that amount the test should fail. If you think that sounds like a good idea, please [@me on Twitter](https://twitter.com/MikeRogers0) and I'll try to get something organised.
7 changes: 0 additions & 7 deletions config.ru
Expand Up @@ -2,10 +2,3 @@ require 'yaml'
require 'rack/jekyll'

run Rack::Jekyll.new()

#if ENV['POW_TIMEOUT']
#watcher = fork do
#exec('bundle exec jekyll build --watch')
#end
#Process.detach(watcher)
#end

0 comments on commit 189aab4

Please sign in to comment.