This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails new myapp -d=postgresql | |
$ cd myapp/ | |
$ git add . | |
$ git commit -m first | |
$ heroku create | |
$ git push heroku master | |
remote: -----> Ruby app detected | |
remote: | |
remote: ! | |
remote: ! You must use Bundler 2 or greater with this lockfile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ $ rails c | |
/app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/compile_cache/iseq.rb:18: [BUG] Segmentation fault at 0x0000000000001994 | |
ruby 2.6.0dev (2018-11-25 schneems/bundler 65963) [x86_64-linux] | |
-- Control frame information ----------------------------------------------- | |
c:0030 p:---- s:0171 e:000170 CFUNC :load_from_binary | |
c:0029 p:0014 s:0166 e:000165 METHOD /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/compile_cache/iseq.rb:18 [FINISH] | |
c:0028 p:---- s:0160 e:000159 CFUNC :fetch | |
c:0027 p:0069 s:0153 e:000152 METHOD /app/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/compile_cache/iseq.rb:37 [FINISH] | |
c:0026 p:---- s:0147 e:000146 CFUNC :require |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/mock' | |
class Foo | |
def foo | |
bar | |
end | |
def bar | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def early_return(val) | |
return val if val | |
"nope" | |
end | |
def compare_if(val) | |
if val | |
val | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10.791165 0.612941 11.447048 ( 12.321773) | |
10.392580 0.607349 11.042279 ( 11.851726) | |
10.735180 0.595994 11.372614 ( 12.300327) | |
10.429255 0.607993 11.079885 ( 11.984101) | |
10.636112 0.618988 11.289580 ( 12.239277) | |
10.350005 0.593711 10.986309 ( 11.958930) | |
10.278313 0.582329 10.912143 ( 12.399119) | |
10.326966 0.571871 10.933312 ( 11.845198) | |
10.623241 0.612042 11.281695 ( 12.252219) | |
10.419475 0.606360 11.061647 ( 12.021191) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
| |
MYARRAY = [["a", ["b", nil, "c", ["d"]]]] | |
| |
Benchmark.ips do |x| | |
x.report("before") { | |
array = MYARRAY.dup | |
array.flatten! | |
array.uniq! | |
array.compact! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13.067572 0.813413 13.924595 ( 15.231642) | |
13.340035 0.831787 14.226155 ( 15.775059) | |
11.818412 0.738438 12.596999 ( 13.704238) | |
10.572116 0.637105 11.253312 ( 12.208787) | |
12.093575 0.718124 12.865758 ( 13.949344) | |
13.526131 0.871625 14.459032 ( 15.760837) | |
10.514290 0.640316 11.197930 ( 12.188919) | |
12.140994 0.763224 12.949930 ( 14.065164) | |
11.631830 0.716007 12.391399 ( 13.485287) | |
10.856942 0.671625 11.574060 ( 12.568493) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
nil_case = nil | |
Benchmark.ips do |x| | |
x.report("nil &. ") { nil_case&.try(:foo) } | |
x.report("nil try") { nil_case.try(:foo) } | |
x.compare! | |
end | |
# Warming up -------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11.783699 0.650146 12.467872 ( 13.422943) | |
12.104542 0.659909 12.797807 ( 13.718245) | |
11.925324 0.636579 12.592296 ( 13.490725) | |
11.299587 0.630098 11.970901 ( 12.859900) | |
11.325793 0.628691 11.995270 ( 13.114663) | |
11.342529 0.631052 12.004864 ( 12.916576) | |
11.387220 0.634889 12.053792 ( 12.978094) | |
11.400185 0.640076 12.078126 ( 13.021475) | |
11.412689 0.640065 12.083551 ( 13.011890) | |
11.363294 0.634647 12.028172 ( 12.959045) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/codetriage/codetriage | |
cd codetriage | |
bundle install | |
cp config/database.example.yml config/database.yml | |
NO_BOOTSNAP=1 bin/rake db:create db:schema:load db:seed | |
NO_BOOTSNAP=1 RAILS_ENV=production RAILS_SERVE_STATIC_FILES=1 RAILS_LOG_TO_STDOUT=1 bundle exec derailed exec perf:test | |
# Runs 5,000 requests against homepage | |
# output is in the form of Benchmark.benchmark | |
13.233374 0.872513 14.143397 ( 19.059944) |