Skip to content

Instantly share code, notes, and snippets.

@tgxworld
Last active August 29, 2015 14:03
Show Gist options
  • Save tgxworld/6851db8cfb2ce143e53b to your computer and use it in GitHub Desktop.
Save tgxworld/6851db8cfb2ce143e53b to your computer and use it in GitHub Desktop.
# Before: Subscribing and unsubscribing to `/render_template.action_view/` every test.
Calculating -------------------------------------
Integration Test 67 i/100ms
Functional Test 91 i/100ms
-------------------------------------------------
Integration Test 691.5 (±6.9%) i/s - 3484 in 5.063611s
Functional Test 938.4 (±5.4%) i/s - 4732 in 5.058631s
# After: Subscribing to `/render_template.actione_view/` only once.
Calculating -------------------------------------
Integration Test 72 i/100ms
Functional Test 97 i/100ms
-------------------------------------------------
Integration Test 735.3 (±6.9%) i/s - 3672 in 5.019675s
Functional Test 963.9 (±5.6%) i/s - 4850 in 5.048307s
require 'test_helper'
require 'benchmark/ips'
class UserFlowTest < ActionDispatch::IntegrationTest
def test_index
get "http://www.example.com/users"
assert_equal 200, response.status
end
end
class UserFlowTest2 < ActionController::TestCase
tests UsersController
def test_index
get :index
assert_equal 200, response.status
end
end
Benchmark.ips(5) do |bm|
bm.report 'Integration Test' do
Minitest.run_one_method(UserFlowTest, 'test_index')
end
bm.report 'Functional Test' do
Minitest.run_one_method(UserFlowTest2, 'test_index')
end
end
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
# GET /users
# GET /users.json
def index
render plain: 'ok'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment