Git Product home page Git Product logo

rails-perftest's Introduction

Performance Testing Rails Applications

This guide covers the various ways of performance testing a Ruby on Rails application.

After reading this guide, you will know:

  • The various types of benchmarking and profiling metrics.
  • How to generate performance and benchmarking tests.
  • How to install and use a GC-patched Ruby binary to measure memory usage and object allocation.
  • The benchmarking information provided by Rails inside the log files.
  • Various tools facilitating benchmarking and profiling.

Performance testing is an integral part of the development cycle. It is very important that you don't make your end users wait for too long before the page is completely loaded. Ensuring a pleasant browsing experience for end users and cutting the cost of unnecessary hardware is important for any non-trivial web application.


Installation

As of rails 4 performance tests are no longer part of the default stack. If you want to use performance tests simply follow these instructions.

Add this line to your application's Gemfile:

gem 'rails-perftest'

If you want to benchmark/profile under MRI or REE, add this line as well:

gem 'ruby-prof'

Now run bundle install and you're ready to go.

Performance Test Cases

Rails performance tests are a special type of integration tests, designed for benchmarking and profiling the test code. With performance tests, you can determine where your application's memory or speed problems are coming from, and get a more in-depth picture of those problems.

Generating Performance Tests

Rails provides a generator called performance_test for creating new performance tests:

$ rails generate performance_test homepage

This generates homepage_test.rb in the test/performance directory:

require 'test_helper'
require 'rails/performance_test_help'

class HomepageTest < ActionDispatch::PerformanceTest
  # Refer to the documentation for all available options
  # self.profile_options = { runs: 5, metrics: [:wall_time, :memory],
  #                          output: 'tmp/performance', formats: [:flat] }

  test "homepage" do
    get '/'
  end
end

Examples

Let's assume your application has the following controller and model:

# routes.rb
root to: 'home#dashboard'
resources :posts

# home_controller.rb
class HomeController < ApplicationController
  def dashboard
    @users = User.last_ten.includes(:avatars)
    @posts = Post.all_today
  end
end

# posts_controller.rb
class PostsController < ApplicationController
  def create
    @post = Post.create(params[:post])
    redirect_to(@post)
  end
end

# post.rb
class Post < ActiveRecord::Base
  before_save :recalculate_costly_stats

  def slow_method
    # I fire gallzilion queries sleeping all around
  end

  private

  def recalculate_costly_stats
    # CPU heavy calculations
  end
end

Controller Example

Because performance tests are a special kind of integration test, you can use the get and post methods in them.

Here's the performance test for HomeController#dashboard and PostsController#create:

require 'test_helper'
require 'rails/performance_test_help'

class PostPerformanceTest < ActionDispatch::PerformanceTest
  def setup
    # Application requires logged-in user
    login_as(:lifo)
  end

  test "homepage" do
    get '/dashboard'
  end

  test "creating new post" do
    post '/posts', post: { body: 'lifo is fooling you' }
  end
end

You can find more details about the get and post methods in the
Testing Rails Applications guide.

Model Example

Even though the performance tests are integration tests and hence closer to the request/response cycle by nature, you can still performance test pure model code.

Performance test for Post model:

require 'test_helper'
require 'rails/performance_test_help'

class PostModelTest < ActionDispatch::PerformanceTest
  test "creation" do
    Post.create body: 'still fooling you', cost: '100'
  end

  test "slow method" do
    # Using posts(:awesome) fixture
    posts(:awesome).slow_method
  end
end

Modes

Performance tests can be run in two modes: Benchmarking and Profiling.

Benchmarking

Benchmarking makes it easy to quickly gather a few metrics about each test run. By default, each test case is run 4 times in benchmarking mode.

To run performance tests in benchmarking mode:

$ rake test:benchmark

To run a single test pass it as TEST:

$ bin/rake test:benchmark TEST=test/performance/your_test.rb

Profiling

Profiling allows you to make an in-depth analysis of each of your tests by using an external profiler. Depending on your Ruby interpreter, this profiler can be native (Rubinius, JRuby) or not (MRI, which uses RubyProf). By default, each test case is run once in profiling mode.

To run performance tests in profiling mode:

$ rake test:profile

Metrics

Benchmarking and profiling run performance tests and give you multiple metrics. The availability of each metric is determined by the interpreter being used—none of them support all metrics—and by the mode in use. A brief description of each metric and their availability across interpreters/modes is given below.

Wall Time

Wall time measures the real world time elapsed during the test run. It is affected by any other processes concurrently running on the system.

Process Time

Process time measures the time taken by the process. It is unaffected by any other processes running concurrently on the same system. Hence, process time is likely to be constant for any given performance test, irrespective of the machine load.

CPU Time

Similar to process time, but leverages the more accurate CPU clock counter available on the Pentium and PowerPC platforms.

User Time

User time measures the amount of time the CPU spent in user-mode, i.e. within the process. This is not affected by other processes and by the time it possibly spends blocked.

Memory

Memory measures the amount of memory used for the performance test case.

Objects

Objects measures the number of objects allocated for the performance test case.

GC Runs

GC Runs measures the number of times GC was invoked for the performance test case.

GC Time

GC Time measures the amount of time spent in GC for the performance test case.

Metric Availability

Benchmarking
Interpreter Wall Time Process Time CPU Time User Time Memory Objects GC Runs GC Time
MRI yes yes yes no yes yes yes yes
REE yes yes yes no yes yes yes yes
Rubinius yes no no no yes yes yes yes
JRuby yes no no yes yes yes yes yes
Profiling
Interpreter Wall Time Process Time CPU Time User Time Memory Objects GC Runs GC Time
MRI yes yes no no yes yes yes yes
REE yes yes no no yes yes yes yes
Rubinius yes no no no no no no no
JRuby yes no no no no no no no

NOTE: To profile under JRuby you'll need to run export JRUBY_OPTS="-Xlaunch.inproc=false --profile.api" before the performance tests.

Understanding the Output

Performance tests generate different outputs inside tmp/performance directory depending on their mode and metric.

Benchmarking

In benchmarking mode, performance tests generate two types of outputs.

Command Line

This is the primary form of output in benchmarking mode. Example:

BrowsingTest#test_homepage (31 ms warmup)
           wall_time: 6 ms
              memory: 437.27 KB
             objects: 5,514
             gc_runs: 0
             gc_time: 19 ms
CSV Files

Performance test results are also appended to .csv files inside tmp/performance. For example, running the default BrowsingTest#test_homepage will generate following five files:

  • BrowsingTest#test_homepage_gc_runs.csv
  • BrowsingTest#test_homepage_gc_time.csv
  • BrowsingTest#test_homepage_memory.csv
  • BrowsingTest#test_homepage_objects.csv
  • BrowsingTest#test_homepage_wall_time.csv

As the results are appended to these files each time the performance tests are run in benchmarking mode, you can collect data over a period of time. This can be very helpful in analyzing the effects of code changes.

Sample output of BrowsingTest#test_homepage_wall_time.csv:

measurement,created_at,app,rails,ruby,platform
0.00738224999999992,2009-01-08T03:40:29Z,,3.0.0,ruby-1.8.7.249,x86_64-linux
0.00755874999999984,2009-01-08T03:46:18Z,,3.0.0,ruby-1.8.7.249,x86_64-linux
0.00762099999999993,2009-01-08T03:49:25Z,,3.0.0,ruby-1.8.7.249,x86_64-linux
0.00603075000000008,2009-01-08T04:03:29Z,,3.0.0,ruby-1.8.7.249,x86_64-linux
0.00619899999999995,2009-01-08T04:03:53Z,,3.0.0,ruby-1.8.7.249,x86_64-linux
0.00755449999999991,2009-01-08T04:04:55Z,,3.0.0,ruby-1.8.7.249,x86_64-linux
0.00595999999999997,2009-01-08T04:05:06Z,,3.0.0,ruby-1.8.7.249,x86_64-linux
0.00740450000000004,2009-01-09T03:54:47Z,,3.0.0,ruby-1.8.7.249,x86_64-linux
0.00603150000000008,2009-01-09T03:54:57Z,,3.0.0,ruby-1.8.7.249,x86_64-linux
0.00771250000000012,2009-01-09T15:46:03Z,,3.0.0,ruby-1.8.7.249,x86_64-linux

Profiling

In profiling mode, performance tests can generate multiple types of outputs. The command line output is always presented but support for the others is dependent on the interpreter in use. A brief description of each type and their availability across interpreters is given below.

Command Line

This is a very basic form of output in profiling mode:

BrowsingTest#test_homepage (58 ms warmup)
        process_time: 63 ms
              memory: 832.13 KB
             objects: 7,882
Flat

Flat output shows the metric—time, memory, etc—measure in each method. Check Ruby-Prof documentation for a better explanation.

Graph

Graph output shows the metric measure in each method, which methods call it and which methods it calls. Check Ruby-Prof documentation for a better explanation.

Tree

Tree output is profiling information in calltree format for use by kcachegrind and similar tools.

Output Availability
Flat Graph Tree
MRI yes yes yes
REE yes yes yes
Rubinius yes yes no
JRuby yes yes no

Tuning Test Runs

Test runs can be tuned by setting the profile_options class variable on your test class.

require 'test_helper'
require 'rails/performance_test_help'

class BrowsingTest < ActionDispatch::PerformanceTest
  self.profile_options = { runs: 5, metrics: [:wall_time, :memory] }

  test "homepage"
    get '/'
  end
end

In this example, the test would run 5 times and measure wall time and memory. There are a few configurable options:

Option Description Default Mode
:runs Number of runs. Benchmarking: 4, Profiling: 1 Both
:output Directory to use when writing the results. tmp/performance Both
:metrics Metrics to use. See below. Both
:formats Formats to output to. See below. Profiling

Metrics and formats have different defaults depending on the interpreter in use.

Interpreter Mode Default metrics Default formats
MRI/REE Benchmarking [:wall_time, :memory, :objects, :gc_runs, :gc_time] N/A
Profiling [:process_time, :memory, :objects] [:flat, :graph_html, :call_tree, :call_stack]
Rubinius Benchmarking [:wall_time, :memory, :objects, :gc_runs, :gc_time] N/A
Profiling [:wall_time] [:flat, :graph]
JRuby Benchmarking [:wall_time, :user_time, :memory, :gc_runs, :gc_time] N/A
Profiling [:wall_time] [:flat, :graph]

As you've probably noticed by now, metrics and formats are specified using a symbol array with each name underscored.

Performance Test Environment

Performance tests are run in the test environment. But running performance tests will set the following configuration parameters:

ActionController::Base.perform_caching = true
ActiveSupport::Dependencies.mechanism = :require if ActiveSupport::Dependencies.respond_to?(:mechanism=)
Rails.logger.level = ActiveSupport::Logger::INFO

As ActionController::Base.perform_caching is set to true, performance tests will behave much as they do in the production environment.

Installing GC-Patched MRI 1.x.x

Since Ruby 2 is now mainstream and handles garbage collection issues these docs have been cut. View older readme explaining how to install optimized Ruby 1 builds.

Command Line Tools

Writing performance test cases could be an overkill when you are looking for one time tests. Rails ships with two command line tools that enable quick and dirty performance testing:

benchmarker

Usage:

Usage: perftest benchmarker 'Ruby.code' 'Ruby.more_code' ... [OPTS]
    -r, --runs N                     Number of runs.
                                     Default: 4
    -o, --output PATH                Directory to use when writing the results.
                                     Default: tmp/performance
    -m, --metrics a,b,c              Metrics to use.
                                     Default: wall_time,memory,objects,gc_runs,gc_time

Example:

$ perftest benchmarker 'Item.all' 'CouchItem.all' --runs 3 --metrics wall_time,memory

profiler

Usage:

Usage: perftest profiler 'Ruby.code' 'Ruby.more_code' ... [OPTS]
    -r, --runs N                     Number of runs.
                                     Default: 1
    -o, --output PATH                Directory to use when writing the results.
                                     Default: tmp/performance
    -m, --metrics a,b,c              Metrics to use.
                                     Default: process_time,memory,objects
    -f, --formats x,y,z              Formats to output to.
                                     Default: flat,graph_html,call_tree

Example:

$ perftest profiler 'Item.all' 'CouchItem.all' --runs 2 --metrics process_time --formats flat

NOTE: Metrics and formats vary from interpreter to interpreter. Pass --help to each tool to see the defaults for your interpreter.

Helper Methods

Rails provides various helper methods inside Active Record, Action Controller and Action View to measure the time taken by a given piece of code. The method is called benchmark() in all the three components.

Model

Project.benchmark("Creating project") do
  project = Project.create("name" => "stuff")
  project.create_manager("name" => "David")
  project.milestones << Milestone.all
end

This benchmarks the code enclosed in the Project.benchmark("Creating project") do...end block and prints the result to the log file:

Creating project (185.3ms)

Please refer to the API docs for additional options to benchmark().

Controller

Similarly, you could use this helper method inside controllers.

def process_projects
  benchmark("Processing projects") do
    Project.process(params[:project_ids])
    Project.update_cached_projects
  end
end

NOTE: benchmark is a class method inside controllers.

View

And in views

<% benchmark("Showing projects partial") do %>
  <%= render @projects %>
<% end %>

Request Logging

Rails log files contain very useful information about the time taken to serve each request. Here's a typical log file entry:

Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET]
Rendering template within layouts/items
Rendering items/index
Completed in 5ms (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items]

For this section, we're only interested in the last line:

Completed in 5ms (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items]

This data is fairly straightforward to understand. Rails uses millisecond(ms) as the metric to measure the time taken. The complete request spent 5 ms inside Rails, out of which 2 ms were spent rendering views and none was spent communication with the database. It's safe to assume that the remaining 3 ms were spent inside the controller.

Useful Links

Rails Plugins and Gems

Generic Tools

Tutorials and Documentation

Commercial Products

Rails has been lucky to have a few companies dedicated to Rails-specific performance tools:

rails-perftest's People

Contributors

aclemons avatar aligit avatar anatol avatar claudiob avatar eliotsykes avatar f1337 avatar jbampton avatar johrstrom avatar mfazekas avatar mistersourcerer avatar nruth avatar rafaelfranca avatar senny avatar y-yagi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rails-perftest's Issues

Repeatable test order

I'm trying to have a repeatable test order without luck.

  setup do
    self.class.test_order = :sorted
  end

How can I achieve that?

Usage of deprecated method `RubyProf.measure_mode`

When running the code with the current version of ruby-prof.

The following information is printed out:

NOTE: RubyProf.measure_mode= is deprecated; use Profile#measure_mode= instead. It will be removed on or after 2023-06.

Segmentation fault

Almost every time when I run rake test:profile I get segmentation fault with really huge backtrace

Cannot insert whole backtrace here.

/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/ruby-prof-0.15.8/lib/ruby-prof/aggregate_call_info.rb:59: [BUG] Segmentation fault at 0x0000000000001c
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0037 p:---- s:0163 e:000162 CFUNC :inject
c:0036 p:0012 s:0159 e:000158 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/ruby-prof-0.15.8/lib/ruby-prof/aggregate_call_info.rb:59
c:0035 p:0011 s:0155 e:000154 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/ruby-prof-0.15.8/lib/ruby-prof/aggregate_call_info.rb:49
c:0034 p:0156 s:0152 e:000150 BLOCK (erb):150 [FINISH]
c:0033 p:---- s:0148 e:000147 CFUNC :each
c:0032 p:0420 s:0145 e:000144 BLOCK (erb):140 [FINISH]
c:0031 p:---- s:0138 e:000137 CFUNC :reverse_each
c:0030 p:0127 s:0135 e:000134 BLOCK (erb):98 [FINISH]
c:0029 p:---- s:0132 e:000131 CFUNC :each
c:0028 p:0066 s:0129 E:0022d8 EVAL (erb):76 [FINISH]
c:0027 p:---- s:0122 e:000121 CFUNC :eval
c:0026 p:0045 s:0115 e:000114 METHOD /home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/erb.rb:863
c:0025 p:0049 s:0111 E:000540 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/ruby-prof-0.15.8/lib/ruby-prof/printers/graph_html_printer.rb:39
c:0024 p:0024 s:0105 e:000104 BLOCK /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance/ruby.rb:54 [FINISH]
c:0023 p:---- s:0102 e:000101 CFUNC :open
c:0022 p:0055 s:0097 E:001f70 BLOCK /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance/ruby.rb:53 [FINISH]
c:0021 p:---- s:0093 e:000092 CFUNC :each
c:0020 p:0042 s:0090 E:001428 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance/ruby.rb:50
c:0019 p:0075 s:0086 E:000c18 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance.rb:118
c:0018 p:0035 s:0080 E:000cb0 BLOCK /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance.rb:71 [FINISH]
c:0017 p:---- s:0076 e:000075 CFUNC :each
c:0016 p:0039 s:0073 E:000b38 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance.rb:69
c:0015 p:0009 s:0069 E:001520 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance.rb:52
c:0014 p:0014 s:0066 E:000788 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:779
c:0013 p:0021 s:0060 E:001218 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:306
c:0012 p:0015 s:0053 E:000728 BLOCK /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:294 [FINISH]
c:0011 p:---- s:0050 e:000049 CFUNC :each
c:0010 p:0010 s:0047 E:001260 BLOCK /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:293
c:0009 p:0040 s:0045 E:001a10 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:332
c:0008 p:0024 s:0038 E:0014b8 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:319
c:0007 p:0070 s:0032 E:002510 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:292
c:0006 p:0014 s:0025 E:001028 BLOCK /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:155 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC :map
c:0004 p:0042 s:0019 E:000678 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:155
c:0003 p:0164 s:0011 E:0013f8 METHOD /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:129
c:0002 p:0073 s:0005 E:000948 BLOCK /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:56 [FINISH]
c:0001 p:0000 s:0002 E:000c90 TOP [FINISH]

-- Ruby level backtrace information ----------------------------------------
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:56:in block in autorun' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:129:inrun'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:155:in __run' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:155:inmap'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:155:in block in __run' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:292:inrun'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:319:in with_info_handler' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:332:inon_signal'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:293:in block in run' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:293:ineach'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:294:in block (2 levels) in run' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:306:inrun_one_method'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/minitest-5.7.0/lib/minitest.rb:779:in run_one_method' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance.rb:52:inrun'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance.rb:69:in _performance_run' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance.rb:69:ineach'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance.rb:71:in block in _performance_run' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance.rb:118:inrun_profile'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance/ruby.rb:50:in record' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance/ruby.rb:50:ineach'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance/ruby.rb:53:in block in record' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance/ruby.rb:53:inopen'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance/ruby.rb:54:in block (2 levels) in record' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/ruby-prof-0.15.8/lib/ruby-prof/printers/graph_html_printer.rb:39:inprint'
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/erb.rb:863:in result' /home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/erb.rb:863:ineval'
(erb):76:in print' (erb):76:ineach'
(erb):98:in block in print' (erb):98:inreverse_each'
(erb):140:in block (2 levels) in print' (erb):140:ineach'
(erb):150:in block (3 levels) in print' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/ruby-prof-0.15.8/lib/ruby-prof/aggregate_call_info.rb:49:incalled'
/home/mbaglay/.rvm/gems/ruby-2.2.0/gems/ruby-prof-0.15.8/lib/ruby-prof/aggregate_call_info.rb:59:in aggregate' /home/mbaglay/.rvm/gems/ruby-2.2.0/gems/ruby-prof-0.15.8/lib/ruby-prof/aggregate_call_info.rb:59:ininject'

-- Machine register context ------------------------------------------------
RIP: 0x00007f1ca0641e97 RBP: 0x00000000012899f0 RSP: 0x00007ffd18a1b540
RAX: 0x0000000000000000 RBX: 0x0000000001289a10 RCX: 0x0000000000000000
RDX: 0x0000000000000000 RDI: 0x00000000012899f0 RSI: 0x0000000001289a10
R8: 0x0000000000000197 R9: 0x000000000e2102b0 R10: 0x0000000000000000
R11: 0x00000000ffffffff R12: 0x0000000000000a00 R13: 0x0000000000000000
R14: 0x00007f1ca068c5c0 R15: 0x000000000000001c EFL: 0x0000000000010202

-- C level backtrace information -------------------------------------------
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_vm_bugreport+0x51f) [0x7f1ca07ff0bf] vm_dump.c:693
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_bug_context+0xcb) [0x7f1ca0692ffb] error.c:389
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(sigsegv+0x52) [0x7f1ca0772e02] signal.c:878
/lib/x86_64-linux-gnu/libc.so.6 [0x7f1ca0286d40]
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(heap_get_freeobj_from_next_freepage+0x107) [0x7f1ca0641e97] gc.c:5164
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(newobj_of+0x12d) [0x7f1ca06bc89d] gc.c:1597
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_node_newnode+0x27) [0x7f1ca06bc937] gc.c:1718
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_iterate+0x3a) [0x7f1ca07e8a8a] vm_eval.c:1075
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_block_call+0x2b) [0x7f1ca07e8cbb] vm_eval.c:1169
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(enum_inject+0x6f) [0x7f1ca068920f] enum.c:662
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1277) [0x7f1ca07ed367] insns.def:1024
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_yield+0x779) [0x7f1ca07f9b89] vm.c:821
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_ary_each+0x52) [0x7f1ca0644af2] array.c:1803
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1277) [0x7f1ca07ed367] insns.def:1024
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_yield+0x779) [0x7f1ca07f9b89] vm.c:821
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_ary_reverse_each+0x3d) [0x7f1ca064583d] array.c:1862
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_method+0x11e) [0x7f1ca07fd5fe] vm_insnhelper.c:1656
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1277) [0x7f1ca07ed367] insns.def:1024
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_yield+0x779) [0x7f1ca07f9b89] vm.c:821
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_ary_each+0x52) [0x7f1ca0644af2] array.c:1803
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_method+0x11e) [0x7f1ca07fd5fe] vm_insnhelper.c:1656
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1277) [0x7f1ca07ed367] insns.def:1024
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(eval_string_with_cref+0x427) [0x7f1ca07f2a17] vm_eval.c:1299
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_f_eval+0x7f) [0x7f1ca07f2fbf] vm_eval.c:1338
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1ada) [0x7f1ca07edbca] insns.def:1054
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_yield+0x779) [0x7f1ca07f9b89] vm.c:821
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_ensure+0xb8) [0x7f1ca069b608] eval.c:907
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1277) [0x7f1ca07ed367] insns.def:1024
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_yield+0x779) [0x7f1ca07f9b89] vm.c:821
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_ary_each+0x52) [0x7f1ca0644af2] array.c:1803
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1277) [0x7f1ca07ed367] insns.def:1024
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_yield+0x779) [0x7f1ca07f9b89] vm.c:821
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_ary_each+0x52) [0x7f1ca0644af2] array.c:1803
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1277) [0x7f1ca07ed367] insns.def:1024
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_yield+0x779) [0x7f1ca07f9b89] vm.c:821
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_ary_each+0x52) [0x7f1ca0644af2] array.c:1803
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1277) [0x7f1ca07ed367] insns.def:1024
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_yield+0x779) [0x7f1ca07f9b89] vm.c:821
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_ary_collect+0x4d) [0x7f1ca064bbbd] array.c:2695
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_cfunc+0x11e) [0x7f1ca07e6dfe] vm_insnhelper.c:1360
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_call_method+0x11e) [0x7f1ca07fd5fe] vm_insnhelper.c:1656
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec_core+0x1277) [0x7f1ca07ed367] insns.def:1024
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_exec+0x84) [0x7f1ca07f1b64] vm.c:1407
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(invoke_block_from_c+0x312) [0x7f1ca07f53a2] vm.c:821
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(vm_invoke_proc+0xe0) [0x7f1ca07f58a0] vm.c:886
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_vm_invoke_proc+0x1a) [0x7f1ca07f595a] vm.c:905
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_proc_call+0x42) [0x7f1ca06a28e2] proc.c:756
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(rb_exec_end_proc+0x13b) [0x7f1ca069c7bb] eval_jump.c:107
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(ruby_finalize_0+0x88) [0x7f1ca069c908] eval.c:119
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(ruby_cleanup+0x240) [0x7f1ca069ccf0] eval.c:177
/home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/libruby.so.2.2(ruby_run_node+0x23) [0x7f1ca069d183] eval.c:309
/home/mbaglay/.rvm/rubies/ruby-2.2.0/bin/ruby(main+0x4b) [0x40088b] main.c:36

-- Other runtime information -----------------------------------------------

  • Loaded script: /home/mbaglay/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/rake_test_loader.rb

Hope that's enough.

Does not load my fixtures

Given this test:

class HomepageTest < ActionDispatch::PerformanceTest
  fixtures :tags

  test "homepage" do
    get '/'
  end
end

I am getting an error in the test because some part of my code, which expects the tag fixtures to present, is crashing because the fixtures are not loaded. Any idea why?

I know the fixture file is fine since it runs in unit tests.

Thanks

why memory and object always zero?

➜  pzz git:(master) ✗ perftest profiler 'PzzUser.first' --runs 3
Run options: --seed 6585

# Running:

ProfilerTest#test_pzzuser_first (35 ms warmup)
        process_time: 13 ms
              memory: 0 Bytes
             objects: 0
.

Finished in 1.732627s, 0.5772 runs/s, 0.0000 assertions/s.

1 runs, 0 assertions, 0 failures, 0 errors, 0 skips

I am using ruby 2.1

Is this project still mantained?

Hi,

Would like to do some benchmark testing. Is this still be mantained? Getting some errors and not finding too much support in SO/Github.

PerformanceTest undefined method `login_as

Problem

I want to login as user to test homepage, when i run RAILS_ENV=benchmark bundle exec rake test:profile, it shows error..._how can i fix this_

PageTest#test_homepage:
NoMethodError: undefined method `login_as' for #<PageTest:0x007faa80dac0f0>
    test/performance/page_test.rb:13:in `setup'

Code

test/performance/page_test.rb

require 'test_helper'
require 'rails/performance_test_help'

class PageTest < ActionDispatch::PerformanceTest
  def setup
    # Application requires logged-in user
    login_as(:user)
  end

  test "homepage" do
    get '/'
  end
end

my benchmark_helper and lib/tasks/test_benchmark.rake are from here http://ccaloha.cc/blog/2015/07/14/howto-performance-test-in-rails-4/

Missing rake tasks

This could be really dumb on my part, but I seem to be missing the relevant rake tasks in Rails 4.0.2 to be able to run the benchmark/profile tests? I'm able to make a test, but running rake -T shows nothing for test:profile or test:benchmark. What am I missing here?

Rails-perftest not working with Minitest 5.11.3

There is currently an issue where minitest 5.11.3 will cause this gem to throw a

minitest.rb:961:in `run_one_method': TestName#run _must_ return a Result (RuntimeError)

This issue is due to a change in minitest which causes the run method to be expected to return a Result instead of just self. The easiest way to fix this is to change the previously linked line in minitest from self to ::Minitest::Result.from self however that will break compatibility with Minitest 4 and < 5.11.

Would the preferred way to fix this be to create a new module called Minitest511AndGreater which handles this properly and then check the version, or is there a better way that I am missing?

uninitialized constant ActionDispatch::PerformanceTest

Rails 6.1.7.3 / rails-perftest 0.0.7

First of all, I've had to deal with both the "don't know how to build test:prepare" and "cannot load such file -- test_helper" errors with various kludges, so I don't know if that's causing ActionDispatch::PerformanceTest not to be initialized.

I added this line to my Rakefile:

task 'test:prepare'

As for the test_helper.rb, I created a new dummy Rails app and copied the test_helper.rb from it:

ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

My test/performance/serializer_test.rb currently is just the boilerplate file from rails generate performance_test serializer.

EDIT: Here's a weird thing I just noticed -- if I require require 'rails/performance_test_help' in a rails console, ActionDispatch::PerformanceTest comes back as a valid constant, so maybe it's worthwhile pasting my benchmark file:

require 'test_helper'
require 'rails/performance_test_help'

class SerializerTest < ActionDispatch::PerformanceTest
  # Refer to the documentation for all available options
  # self.profile_options = { runs: 5, metrics: [:wall_time, :memory],
  #                          output: 'tmp/performance', formats: [:flat] }

  test "homepage" do
    get '/'
  end
end

I'm also invoking the test like this: bundle exec rails test:benchmark TEST=test/performance/serializer_test.rb

Compatibility with Rails 5

sub_test_task.rb was removed in Rails 5.0

$ rake
LoadError: cannot load such file -- rails/test_unit/sub_test_task
rails-perftest-0.0.6/lib/rails/perftest/railties/testing.tasks:1:in `<top (required)>'

See: https://github.com/Mehonoshin/draper/pull/2/files

For possible solution. Until this is resolved the following monkey patch can be used:

+++ lib/rails/test_unit/sub_test_task.rb

# Monkey patch, gem rails-perftest
require 'rake/testtask'
class Rails::SubTestTask < Rake::TestTask
end

Rails 5 compatibility?

Running rake test:benchmark on a Rails app generated from the current master rails/rails@5746638 raises an error:

LoadError: cannot load such file -- rails/test_unit/sub_test_task
.../rails-perftest-4faa9b5314cc/lib/rails/perftest/railties/testing.tasks:1:in `require'

The reason is that this line of code requires rails/test_unit/sub_test_task but Rails 5 does not have this file anymore since it was removed in 3297909.

Thanks again for this great library! 👑

It fails on Rails 5 with LoadError: cannot load such file -- rails/test_unit/sub_test_task

LoadError: cannot load such file -- rails/test_unit/sub_test_task
.../.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/dependencies.rb:302:in `require'
.../.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/dependencies.rb:302:in `block in require'
.../.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/dependencies.rb:268:in `load_dependency'
.../.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/dependencies.rb:302:in `require'
.../.rvm/gems/ruby-2.2.4/gems/rails-perftest-0.0.6/lib/rails/perftest/railties/testing.tasks:1:in `<top (required)>'
.../.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/dependencies.rb:296:in `load'
.../.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/dependencies.rb:296:in `block in load'
.../.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/dependencies.rb:268:in `load_dependency'
.../.rvm/gems/ruby-2.2.4/gems/activesupport-5.0.0.beta2/lib/active_support/dependencies.rb:296:in `load'
.../.rvm/gems/ruby-2.2.4/gems/rails-perftest-0.0.6/lib/rails/perftest/railtie.rb:8:in `block in <class:Railtie>'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/railtie.rb:237:in `instance_exec'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/railtie.rb:237:in `block in run_tasks_blocks'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/railtie.rb:245:in `each'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/railtie.rb:245:in `each_registered_block'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/railtie.rb:237:in `run_tasks_blocks'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/application.rb:440:in `block in run_tasks_blocks'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/engine/railties.rb:13:in `each'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/engine/railties.rb:13:in `each'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/application.rb:440:in `run_tasks_blocks'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/engine.rb:457:in `load_tasks'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/railtie.rb:194:in `public_send'
.../.rvm/gems/ruby-2.2.4/gems/railties-5.0.0.beta2/lib/rails/railtie.rb:194:in `method_missing'

This is similar to drapergem/draper#681 .
Rails 5 no longer has rails/test_unit/sub_test_task

Compatibility with ruby-prof 0.16

See https://github.com/ruby-prof/ruby-prof/blob/master/CHANGES , there are major changes to the print method in commit: ruby-prof/ruby-prof@24a267b

After upgrading ruby-prof to 0.16.x I get this error message:

...gems/ruby-prof-0.16.2/lib/ruby-prof/printers/call_tree_printer.rb:46
  in `print': wrong number of arguments (2 for 0..1) (ArgumentError)
...gems/rails-perftest-0.0.6/lib/rails/perftest/active_support/testing/performance/ruby.rb:54
  in `block (2 levels) in record'

ruby-prof print now takes one options = {} argument

Existing integration tests hook?

Why can't I run performance tests against existing integration tests? I'm not going to have duplicate integration tests just for performance.

Is there a way to avoid executing test:prepare?

I need to test the performance of my website with real data, I wont spend the time creating millions of fixture records to do this, so is there a way to test my application with a copy of my production data without having it replaced by fixtures? I've tried creating a new benchmark environment for my rails app with numerous tutorials and none have worked. Is there a way to do this?

gcpatch for Ruby 2.1

Is there a gcpatch patch for Ruby 2.1? without out my memory profiles are empty. But i havent been able to find any information on this. TIA

compatibility issue with the latest version of ruby-prof (0.12.0)

When using the latest version of ruby-prof I get:

/Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/rails-perftest-0.0.1/lib/rails/perftest/active_support/testing/performance/ruby.rb:38:in `run': undefined method `pause' for RubyProf:Module (NoMethodError)
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/rails-perftest-0.0.1/lib/rails/perftest/active_support/testing/performance.rb:90:in `run_profile'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/rails-perftest-0.0.1/lib/rails/perftest/active_support/testing/performance.rb:45:in `block in run'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/rails-perftest-0.0.1/lib/rails/perftest/active_support/testing/performance.rb:43:in `each'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/rails-perftest-0.0.1/lib/rails/perftest/active_support/testing/performance.rb:43:in `run'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:916:in `block in _run_suite'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:909:in `map'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:909:in `_run_suite'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:896:in `block in _run_suites'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:896:in `map'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:896:in `_run_suites'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:864:in `_run_anything'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:1057:in `run_tests'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:1044:in `block in _run'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:1043:in `each'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:1043:in `_run'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:1032:in `run'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@rails-app/gems/minitest-4.4.0/lib/minitest/unit.rb:786:in `block in autorun'

can't clone the repository

This is what happens:

$ git clone https://github.com/rails/rails-perftest.git
Cloning into 'rails-perftest'...
remote: Counting objects: 297, done.
remote: Total 297 (delta 0), reused 0 (delta 0), pack-reused 297
Receiving objects: 100% (297/297), 49.14 KiB | 0 bytes/s, done.
Resolving deltas: 100% (120/120), done.
Checking connectivity... done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Can you please fix this?

Don't know how to build task 'test:prepare'

Hello there

I'm using the rails-perftest and ruby-prof and trying to run test using benchmarks project but I have an issue with the rake task:

bti:ams-jbuilder-pg/ (ams✗) $ rake test:benchmark
rake aborted!
Don't know how to build task 'test:prepare'
/Users/bti/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `load'
/Users/bti/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `block in load'
/Users/bti/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:232:in `load_dependency'
/Users/bti/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `load'
-e:1:in `<main>'
Tasks: TOP => test:benchmark
(See full trace by running task with --trace)

No problem with the generator.

bti:ams-jbuilder-pg/ (ams✗) $ rails generate performance_test homepage
      create  test/performance/homepage_test.rb

Any ideas of the problem?

Out of sync with ruby-prof

Hi I wanted to know if rails-perftest is "out of date" and if there are other options that offer something similar. I tried running a performance test locally on rails 5.2 and ruby 2.5.8 but got lots of errors. I checked the fork network on github and found this commit which got it working beansmile@bdb96c5. Maybe rails-perftest just needs those changes to start working again with the latest version of ruby-prof?

memory: unsupported and objects: unsupported

I have rails 4.1.7 and ruby 2.0.0p643. Not sure this gem support ruby 2.0.0p643. Below is the result I got

$ bundle exec rake test:benchmark
Run options: --seed 19167

# Running:

ChatFeedTest#test_Public_feeds (274 ms warmup)
           wall_time: 16 ms
              memory: unsupported
             objects: unsupported
             gc_runs: 0
             gc_time: -80 ms
.FeedModelTest#test_creation (109 ms warmup)
           wall_time: 7 ms
              memory: unsupported
             objects: unsupported
             gc_runs: 0
             gc_time: 0 ms

Assertions for performance metrics

I expected examples on how to assert global and testcase-specific assertions on performance metrics. For example, ensuring no single integration test runs for longer than a second, but allowing local test case overrides for special cases.

rails-perftest `require': cannot load such file — test_helper (LoadError)

I try execute benchmark test with perftest, but rake crashes with error message require': cannot load such file -- test_helper (LoadError)

The complete return error message with trace ( bundle exec rake test:benchmark --trace ) is:

/home/app/tracker/test/performance/homepage_test.rb:1:in `require': cannot load such file -- test_helper (LoadError)
from /home/app/tracker/test/performance/homepage_test.rb:1:in `<top (required)>'
from /home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_test_loader.rb:10:in `require'
from /home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_test_loader.rb:9:in `each'
from /home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_test_loader.rb:4:in `select'
from /home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib" "/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_test_loader.rb" "test/performance/**/*_test.rb" ]
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/testtask.rb:108:in `block (3 levels) in define'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/file_utils.rb:45:in `call'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/file_utils.rb:45:in `sh'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/file_utils_ext.rb:37:in `sh'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/file_utils.rb:84:in `ruby'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/file_utils_ext.rb:37:in `ruby'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/testtask.rb:104:in `block (2 levels) in define'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/file_utils_ext.rb:58:in `verbose'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/testtask.rb:100:in `block in define'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/user/.rbenv/versions/2.1.4/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/home/user/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/home/user/.rbenv/versions/2.1.4/bin/rake:23:in `load'
/home/user/.rbenv/versions/2.1.4/bin/rake:23:in `<main>'
Tasks: TOP => test:benchmark

With Rails 4.0.11 and Ruby 2.1.4

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.