Skip to content

Instantly share code, notes, and snippets.

@tgxworld
Last active August 29, 2015 14:03
Show Gist options
  • Save tgxworld/a518e63a54d82161ceb9 to your computer and use it in GitHub Desktop.
Save tgxworld/a518e63a54d82161ceb9 to your computer and use it in GitHub Desktop.
Disabling Logging
# Logging enabled
Calculating -------------------------------------
GET Integration Test 35 i/100ms
GET Functional Test 43 i/100ms
POST Integration Test 35 i/100ms
POST Functional Test 46 i/100ms
-------------------------------------------------
GET Integration Test 369.3 (±8.7%) i/s - 1855 in 5.068452s
GET Functional Test 452.1 (±12.4%) i/s - 2236 in 5.047780s
POST Integration Test 356.8 (±5.9%) i/s - 1785 in 5.020104s
POST Functional Test 469.8 (±4.9%) i/s - 2346 in 5.006985s
# Logger level set to Logger::FATAL
Calculating -------------------------------------
GET Integration Test 41 i/100ms
GET Functional Test 50 i/100ms
POST Integration Test 40 i/100ms
POST Functional Test 50 i/100ms
-------------------------------------------------
GET Integration Test 363.4 (±9.4%) i/s - 1845 in 5.124344s
GET Functional Test 418.9 (±14.3%) i/s - 2050 in 5.003909s
POST Integration Test 366.0 (±10.4%) i/s - 1840 in 5.092436s
POST Functional Test 474.3 (±6.7%) i/s - 2400 in 5.085053s
require 'test_helper'
require 'benchmark/ips'
# Rails.logger.level = 4
class UserFlowTest < ActionDispatch::IntegrationTest
def test_get
get "/users"
assert_equal 200, response.status
end
def test_post
post "/users", { user: { first_name: 'Alan', last_name: 'Tan' } }
assert_equal 302, response.status
end
end
class UserFlowTest2 < ActionController::TestCase
tests UsersController
def test_get
get :index
assert_equal 200, response.status
end
def test_post
post :create, { user: { first_name: 'Alan', last_name: 'Tan' } }
assert_equal 302, response.status
end
end
Benchmark.ips(5) do |bm|
bm.report 'GET Integration Test' do
Minitest.run_one_method(UserFlowTest, 'test_get')
end
bm.report 'GET Functional Test' do
Minitest.run_one_method(UserFlowTest2, 'test_get')
end
bm.report 'POST Integration Test' do
Minitest.run_one_method(UserFlowTest, 'test_post')
end
bm.report 'POST Functional Test' do
Minitest.run_one_method(UserFlowTest2, 'test_post')
end
end
class UsersController < ApplicationController
def index
@users = User.all
end
def create
@user = User.new(user_params)
if @user.save
flash[:success] = 'User was successfully created.'
redirect_to @user
else
render 'new'
end
end
private
def user_params
params.require(:user).permit(:first_name, :last_name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment