Coder Social home page Coder Social logo

alexsydney / rspec-prof Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sinisterchipmunk/rspec-prof

0.0 2.0 0.0 60 KB

Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec examples.

Home Page: http://www.thoughtsincomputation.com

License: MIT License

Ruby 75.60% Gherkin 24.40%

rspec-prof's Introduction

Integrates ruby-prof with RSpec, allowing you to easily profile your RSpec examples.

Installation

If you need to use rspec-prof in Rails 2.x or RSpec 1.x, use version ‘0.0.3`.

Gemfile:

group :test do
  gem 'rspec-prof'
end

Usage

The easiest way to use rspec-prof is to export the ‘RSPEC_PROFILE` environment variable:

$ rake spec RSPEC_PROFILE=each

This will cause every spec to be profiled individually. The output will be placed in ‘./profiles` by default.

To execute all specs as parts of a single profile, export ‘RSPEC_PROFILE=all` instead.

Configuration

You can set some configuration options for ‘rspec-prof`, as long as you do so before `RSpec` begins running specs. Thus, the best place for this configuration is in `spec/support/rspec-prof.rb`.

Valid configuration options and their default values are:

RSpecProf.printer_class = RubyProf::GraphHtmlPrinter
  # The printer to be used when writing profiles

RSpecProf::FilenameHelpers.file_extension = "html"
  # The file extension for profiles written to disk

RSpecProf::FilenameHelpers.output_dir = "profiles"
  # The destination directory into which profiles are written

Pausing and Resuming

It is perfectly OK to do this:

require 'spec_helper'

describe "smth" do
  before do
    # let's not profile the test set-up
    RubyProf.pause if RubyProf.running?

    sleep 30 # doing something expensive...

    # don't forget to resume so specs can be measured!
    RubyProf.resume if RubyProf.running?
  end
end

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Colin MacKenzie IV. See LICENSE for details.

rspec-prof's People

Contributors

sinisterchipmunk avatar squaresurf avatar gravityrail avatar jrafanie avatar ged avatar tobypinder avatar

Watchers

James Cloos avatar Alex Pham 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.