GithubHelp home page GithubHelp logo

bhanditz / rspec-gc-control Goto Github PK

View Code? Open in Web Editor NEW

This project forked from airbnb/rspec-gc-control

0.0 2.0 0.0 21 KB

Add a mechanism to control the garbage collector in RSpec.

License: MIT License

Ruby 84.93% Gherkin 15.07%

rspec-gc-control's Introduction

rspec-gc-control

Code Climate

Summary

This gem extends RSpec to allow you to control how often GC cycles happen in order to trade increased memory usage for faster test runs. It's an encapsulated and reusable version of the code shown in this article:

http://www.rubyinside.com/careful-cutting-to-get-faster-rspec-runs-with-rails-5207.html

Requirements

For this to work, you need a Ruby that supports explicit control over the garbage collector, and RSpec 2.11.1 or higher.

Supported Rubies include MRI 1.9.2 and 1.9.3, and most likely Rubinius.

Unsupported Rubies are:

  • MRI 1.8.x: No support for GC.count.
  • JRuby: GC.enable / GC.disable are no-ops.

On unsupported platforms, attempting to enable explicit GC control via this plugin will produce a warning and have no other effect.

Installation and Usage

Install the gem:

gem install rspec-gc-control

Or if you're using bundler, add this line to your Gemfile and run bundle install:

gem 'rspec-gc-control'

Once you have the gem installed, edit your spec_helper.rb file to set gc_every_n_examples to an appropriate value. You may want to play with this value while watching memory consumption for the process to get a feeling for how significant a tradeoff you're making in terms of increased memory usage.

RSpec.configure do |c|
  c.gc_every_n_examples = 10
end

You'll know it's working if you see output like the following at the end of your test run:

Finished in 6.45 seconds (including 7 forced GC cycle(s), totalling 0.67116 seconds)
71 examples, 0 failures, 1 pending

rspec-gc-control's People

Contributors

mrjoy avatar evie404 avatar

Watchers

James Cloos 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.