Skip to content

Instantly share code, notes, and snippets.

@tgxworld
Last active August 29, 2015 14:02
Show Gist options
  • Save tgxworld/7f977743788cf019de9d to your computer and use it in GitHub Desktop.
Save tgxworld/7f977743788cf019de9d to your computer and use it in GitHub Desktop.
Initial Benchmark
require 'test_helper'
require 'benchmark/ips'
class UserFlowTest < ActionDispatch::IntegrationTest
def test_index
get 'http://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(30) 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
<h1>Listing users</h1>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New User', new_user_path %>
Rails.application.routes.draw do
resources :users
end
# Before https://github.com/rails/rails/commit/4fd144dd4bb0e1ede5a4857c178138088353a3d1 on May 13
Calculating -------------------------------------
Integration Test 34 i/100ms
Functional Test 43 i/100ms
-------------------------------------------------
Integration Test 352.6 (±7.7%) i/s - 10540 in 30.075333s
Functional Test 445.1 (±7.4%) i/s - 13287 in 30.018357s
# After on June 12
Calculating -------------------------------------
Integration Test 37 i/100ms
Functional Test 46 i/100ms
-------------------------------------------------
Integration Test 367.0 (±4.1%) i/s - 11026 in 30.095082s
Functional Test 453.8 (±3.1%) i/s - 13616 in 30.031817s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment