Skip to content

Instantly share code, notes, and snippets.

@tgxworld
Last active August 29, 2015 14:03
Show Gist options
  • Save tgxworld/2770ab27e2dc6ac941fb to your computer and use it in GitHub Desktop.
Save tgxworld/2770ab27e2dc6ac941fb to your computer and use it in GitHub Desktop.
Rack Parser Regression
# Before
Calculating -------------------------------------
GET 35 i/100ms
POST 34 i/100ms
-------------------------------------------------
GET 357.4 (±3.4%) i/s - 1785 in 4.999583s
POST 341.5 (±3.8%) i/s - 1734 in 5.084699s
# After
Calculating -------------------------------------
GET 23 i/100ms
POST 23 i/100ms
-------------------------------------------------
GET 242.5 (±3.3%) i/s - 1219 in 5.032013s
POST 235.2 (±3.4%) i/s - 1196 in 5.091327s
require 'test_helper'
require 'benchmark/ips'
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
Benchmark.ips(5) do |bm|
bm.report 'GET Integration Test' do
Minitest.run_one_method(UserFlowTest, 'test_get')
end
bm.report 'POST Integration Test' do
Minitest.run_one_method(UserFlowTest, '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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment