Code Monkey home page Code Monkey logo

bloat_check's Introduction

bloat_check

BloatCheck is yet another tool for debugging bloat and memory leaks in ruby projects. This one has the feature that you can wrap any bit of code with a “BloatCheck” and it will log elapsed time, and memory & object growth.

Plus you can include it in any rails controller to log that same info per request.

Installation

Gemfile:

gem 'bloat_check'

Usage: Ruby Code

Put this line anywhere:

BloatCheck.log("some label")

and it will write to the log the current time, process memory size, and 5 ruby objects classes with most instances, prefixed with “BLOAT” and your label.

Wrap it around any existing code, such as

BloatCheck.log("here's looking at you") do
    some_suspec_computation()
    and_more()
end

And it will write to the log the deltas: elapsed time, change in memory size, and 5 ruby object classes that had the largest increase in number of instances.

Usage: Rails Controllers

In a rails controller, you can do

class MyController < ApplicationController
    include BloatCheck::WrapRequests

    # etc.
end

and every request will log the deltas incurred during that request.

Disabling (e.g., when running tests)

BloatCheck is slow (calls system ‘ps’, and runs through ObjectSpace#each_object), so you might want to disable it in your unit tests or integration tests. Do that via:

BloatCheck.disable = true

Put this, e.g. in your spec/spec_helper.rb file

Choosing the logger

By default, BloatCheck logs to the Rails logger if Rails is defined, or to STDOUT otherwise. But you can specify your own logger using

BloatCheck.logger = Logger.new(...)

Versions

Has been tested on MRI 1.9.3 and Rails 3.2

History

Released under the MIT License. See LICENSE for details.

bloat_check's People

Contributors

face avatar ronen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.