Skip to content

Instantly share code, notes, and snippets.

View schneems's full-sized avatar

Richard Schneeman schneems

View GitHub Profile
require 'benchmark/ips'
env = {"foo" => "bar", "bar" => "baz", "baz" => "boo", "PATH_INFO" => "foo"}
Benchmark.ips do |x|
x.report("set and reset") do
env["PATH_INFO"] = "zoo"
env
env["PATH_INFO"] = "foo"
end
require 'benchmark/ips'
env = {"foo" => "bar", "bar" => "baz", "baz" => "boo", "PATH_INFO" => "foo"}
Benchmark.ips do |x|
x.report("set and reset") do
env["PATH_INFO"] = "zoo"
env
env["PATH_INFO"] = "foo"
end
require 'benchmark'
require 'tmpdir'
require 'thread'
AWS.config(access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'))
THREADS_TO_RUN = Integer(ENV["THREADS"] || 2)
store= AWS::S3.new.buckets[ENV.fetch('AWS_BUCKET')].objects
allocated memory by gem
-----------------------------------
rack-1.5.2 x 6491
actionpack-4.1.2 x 4888
hashie-2.1.1 x 4615
activesupport-4.1.2 x 4523
omniauth-1.2.1 x 1387
actionview-4.1.2 x 1107
ruby-2.1.2/lib x 1097
railties-4.1.2 x 925
namespace :perf do
task :setup do
require 'benchmark/ips'
require 'rack/file'
require 'time'
require 'rack/test'
require 'get_process_mem'
TEST_CNT = (ENV['TEST_CNT'] || ENV['CNT'] || 1_000).to_i
@schneems
schneems / gist:698df49c8c22cfea1d2c
Created October 29, 2014 20:49
Ruby 2.2.0 string allocation microbenchmarks

Accessing a hash

require 'benchmark/ips'

FOO  = "foo".freeze
HASH = {"foo" => "bar"}
Benchmark.ips do |x|
  x.report("constant") { HASH[FOO] }
 x.report("regular") { HASH["foo"]}
list = `gem list`
list.each_line do |line|
next unless line.match(/\(/)
name = line.split("(").first
cmd = "gem uninstall #{name} --force --executables"
puts cmd
result = `#{cmd}`
puts result unless $?.success?
end

In response to omniauth/omniauth#773 (comment)

Responses to your comments in turn.

I'd feel worse about omniaith with this pull request than without.

Agreed, that's why we closed it. This PR didn't go far enough. It tried to support the current interface, in its (almost) entirety when the right way to do it would be to introduce proper config with real honest to goodness objects and methods. I talked about this omniauth/omniauth#773 (comment)

I feel that it's taking on a chunk of technical debt.

source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.0.0.alpha', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets