Skip to content

Instantly share code, notes, and snippets.

View tgxworld's full-sized avatar
🇸🇬

Alan Guo Xiang Tan tgxworld

🇸🇬
View GitHub Profile
@tgxworld
tgxworld / benchmark.rb
Last active August 29, 2015 14:03
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 -------------------------------------
@tgxworld
tgxworld / benchmark.rb
Last active August 29, 2015 14:03
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
require 'byebug'
integration = []
File.open('/home/guoxiang/app2/itest.txt', 'r').each_line do |line|
line.match(/Finished in ([\d.]+)/)
integration << $1.to_f if $1
end
functional = []
File.open('/home/guoxiang/app2/ftest.txt', 'r').each_line do |line|
@tgxworld
tgxworld / Log
Last active August 29, 2015 14:03
Comparison between Controller and Integration tests for https://github.com/fxn/rails-contributors
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (integration) $ time for i in {1..100}; do rake test:controllers; done >> integration.txt
real 2m56.749s
user 2m37.466s
sys 0m15.781s
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (integration) $ time for i in {1..100}; do rake test:controllers; done >> controller.txt
real 2m57.044s
user 2m37.664s
sys 0m15.830s
@tgxworld
tgxworld / log.rb
Last active August 29, 2015 14:04
Comparison of runtime between Controllers and Integration Tests. (Rspec included)
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (master) $ time rspec spec/controllers
..............................................................................................................
Finished in 3.34 seconds
110 examples, 0 failures
Randomized with seed 12942
real 0m4.700s
@tgxworld
tgxworld / 100_runs.rb
Last active August 29, 2015 14:04
Comparison of runtime between Controllers and Integration Tests.
# Logging Enabled
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (master) $ time for i in {1..100}; do rake test:controllers; done;
real 2m59.920s
user 2m39.629s
sys 0m16.733s
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (master) $ time for i in {1..100}; do rake test:integration; done;
real 3m5.075s
user 2m44.631s
sys 0m16.883s
@tgxworld
tgxworld / 100_runs.rb
Created July 17, 2014 05:47
Comparison of runtime between Controllers and Integration Tests. Duplicated test case 10 times to simulate a larger test suite.
real 7m15.452s
user 6m45.995s
sys 0m19.915s
@tgxworld
tgxworld / 100_runs.rb
Created July 17, 2014 05:47
Comparison of runtime between Controllers and Integration Tests. Duplicated test case 10 times to simulate a larger test suite.
real 7m15.452s
user 6m45.995s
sys 0m19.915s
@tgxworld
tgxworld / 100_runs.rb
Last active August 29, 2015 14:04
Comparison of runtime between Controllers and Integration Tests. Duplicated test case 10 times to simulate a larger test suite.
# Logging Enabled
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (master) $ time for i in {1..100}; do rake test:controllers; done;
real 7m47.588s
user 7m14.987s
sys 0m23.319s
guoxiang@guoxiang-GS60-2PC-Ghost rails-contributors (master) $ time for i in {1..100}; do rake test:integration; done;
real 8m25.046s
user 7m51.508s
sys 0m24.071s
@tgxworld
tgxworld / gist:de167eb9cefa3d73f660
Last active August 29, 2015 14:06
Bound Parameters
require 'abstract_unit'
class SomethingController < ApplicationController
def index
render plain: 'ok'
end
end
class SomethingTest < ActionDispatch::IntegrationTest
class SomeController < ApplicationController