Skip to content

Instantly share code, notes, and snippets.

View tgxworld's full-sized avatar
🇸🇬

Alan Guo Xiang Tan tgxworld

🇸🇬
View GitHub Profile
# profile_test.rb
require 'abstract_unit'
require 'benchmark'
require 'benchmark/ips'
require 'ruby-prof'
class AController < ActionController::Base
def index
render html: 'ok'
@tgxworld
tgxworld / gist:51b0ed1fbc220a0c168f
Last active August 29, 2015 14:01
Sample test file
require 'abstract_unit'
require 'benchmark'
require 'benchmark/ips'
require 'ruby-prof'
class AController < ActionController::Base
def index
render html: 'ok'
end
end
require 'abstract_unit'
require 'benchmark/ips'
require 'ruby-prof'
class AController < ActionController::Base
def index
render html: 'ok'
end
end
@tgxworld
tgxworld / gist:c1641dd18bea614ca216
Last active August 29, 2015 14:02
Notifications
require 'abstract_unit'
require 'benchmark/ips'
require 'ruby-prof'
class AController < ActionController::Base
def index
render html: 'ok'
end
end
@tgxworld
tgxworld / a.rb
Last active August 29, 2015 14:02
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
@tgxworld
tgxworld / index.html.erb
Last active August 29, 2015 14:02
Benchmark with Large RouteSet
<h1>Listing users</h1>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
# Calculated based on 400 requests.
ActionDispatch::Routing::RouteSet
sum: 3.1608972460000047 mean: 0.0019755607787500028 median: 0.001745662.
Rack::ETag
sum: 0.06956181100000014 mean: 4.3476131875000085e-05 median: 3.7703499999999996e-05.
Rack::ConditionalGet
sum: 0.055353544999999955 mean: 3.4595965624999973e-05 median: 2.8501500000000174e-05.
Rack::Head
sum: 0.022108525999999972 mean: 1.3817828749999982e-05 median: 1.1781000000000096e-05.
# Before https://github.com/rails/rails/commit/4fd144dd4bb0e1ede5a4857c178138088353a3d1 on May 13
Calculating -------------------------------------
Integration Test 58 i/100ms
Functional Test 87 i/100ms
-------------------------------------------------
Integration Test 605.9 (±9.7%) i/s - 3016 in 5.030043s
Functional Test 877.5 (±11.4%) i/s - 4350 in 5.030839s
# with Turbolinks before/after filter
# 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.
@tgxworld
tgxworld / benchmark.rb
Last active August 29, 2015 14:03
Disabling Logging and Skipping Turbolinks filter
# Before https://github.com/rails/rails/commit/4fd144dd4bb0e1ede5a4857c178138088353a3d1 on May 13
Calculating -------------------------------------
Integration Test 59 i/100ms
Functional Test 84 i/100ms
-------------------------------------------------
Integration Test 599.5 (±11.0%) i/s - 3009 in 5.087300s
Functional Test 882.1 (±10.2%) i/s - 4368 in 5.008871s
# Benchmark as of July 8