github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

timocratic / test_benchmark

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 67
    • 4
  • Source
  • Commits
  • Network (4)
  • Issues (3)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (2)
    • master ✓
    • output_once
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Rails plugin (and/or ruby gem) for benchmarking your test::units: a rework of the original by topfunky — Read more

  cancel

http://www.timocracy.com/articles/2009/01/13/a-revamped-plugin-gem-for-benchmarking-your-ruby-rails-test-units

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Vijay: Exit running the tests if there are any failures. Some minor 
refactoring to reuse methods from test unit runner. 
Vijay Aravamudhan (author)
Sat Nov 14 11:53:59 -0800 2009
timocratic (committer)
Sat Nov 14 12:33:40 -0800 2009
commit  c7c1f229312e97cbb656151323ecb10337c3f4b8
tree    992c69eea0cb7c1f2551bb29d865cfcf248ca72a
parent  1b773c52e8a321c0e0ba4c156f3660870764fcb1
test_benchmark /
name age
history
message
file History.txt Sun Oct 11 23:55:28 -0700 2009 Bump version to force GitHub rebuild [ffmike]
file Manifest.txt Sun Jun 24 21:41:47 -0700 2007 Updated manifest [Geoffrey Grosenbach]
file README.textile Sun Oct 11 23:55:20 -0700 2009 Update history & readme [ffmike]
file Rakefile Sun Jun 24 21:41:47 -0700 2007 Updated manifest [Geoffrey Grosenbach]
file about.yml Thu Sep 21 10:37:11 -0700 2006 First import [Geoffrey Grosenbach]
file init.rb Mon Apr 06 12:53:41 -0700 2009 I had a problem using a script from script/runn... [look]
directory lib/ Sat Nov 14 12:33:40 -0800 2009 Vijay: Exit running the tests if there are any ... [Vijay Aravamudhan]
directory test/ Tue Jan 13 10:57:05 -0800 2009 testing installed gem [timocratic]
file test_benchmark.gemspec Tue Oct 13 13:59:20 -0700 2009 updating authors list [timocratic]
README.textile

Test Benchmark

A ruby gem and rails plugin to show you how slow your Test::Unit tests run. Useful for troubleshooting/isolating slow tests. Available from http://github.com/timocratic/test_benchmark/

Sample output:


  7.124 test_destroy(FeedTest)
  7.219 test_create(FeedTest)
  7.646 test_subscribe_to_auto_discovery(FeedTest)
  9.339 test_auto_discover_updates_url(FeedTest)
  9.543 test_find_or_create_by_auto_discover_url(FeedTest)
  15.780 test_import_from_opml(FeedTest)

Install and enable

As a Rails Plugin

./script/plugin install git://github.com/timocratic/test_benchmark.git

As a Ruby gem

Install

  • Update to RubyGems 1.2.0+ before proceeding!!
  • gem sources -a http://gems.github.com (you only have to do this once)
  • sudo gem install timocratic-test_benchmark

Enable

  • require ‘rubygems’
  • require ’test_benchmark

As a (frozen) gem in rails

I recommend this method. It makes updating simple, and if I had more config in the future, that will be easily done only in your test environment

in config/environments/test.rb


config.gem "timocratic-test_benchmark", :lib => 'test_benchmark', :source => 'http://gems.github.com', :version => '0.4.2' #update to whatever version number is current

from the console


RAILS_ENV=test GEM=timocratic-test_benchmark rake gems:install
RAILS_ENV=test GEM=timocratic-test_benchmark rake gems:unpack #optional, but suggested step - 'freezing' the gem

Options and disabling temporarily

By default the top 15 slowest tests are output to the console (and in Rails the whole list is dumped to test.log). To see the full dump in your console (as well as get a per-file/suite breakdown) set the env variable BENCHMARK to ‘full’:

BENCHMARK=full rake test

To disable completely, run with it set to ‘false’ instead.

You can also customize the number of results through the Test::Unit::UI::Console::TestRunner.set_test_benchmark_limits(set_display_limit, set_suite_display_limit) method. For example, putting this line in your test_helper.rb file will output a summary of 5 slowest tests and 3 slowest test classes:


Test::Unit::UI::Console::TestRunner.set_test_benchmark_limits(5, 3)

And this will disable output entirely:


Test::Unit::UI::Console::TestRunner.set_test_benchmark_limits(0, 0)
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server