Skip to content

Instantly share code, notes, and snippets.

View flyerhzm's full-sized avatar
🏠
Working from home

Richard Huang flyerhzm

🏠
Working from home
View GitHub Profile
@flyerhzm
flyerhzm / railsbp_sinatra_proxy_deploy_example
Created February 1, 2012 10:51
railsbp sinatra proxy deploy example
require 'bundler/capistrano'
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, 'ruby-1.9.2@sinatra-proxy' # Or whatever env you want it to run in.
set :rvm_bin_path, "/usr/local/rvm/bin"
set :application, "railsbp sinatra proxy"
set :repository, "git://github.com/railsbp/sinatra-proxy.git"
set :scm, :git
@flyerhzm
flyerhzm / gist:1746308
Created February 5, 2012 16:14
railsbp rails proxy deploy example
require 'bundler/capistrano'
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, 'ruby-1.9.2@rails-proxy' # Or whatever env you want it to run in.
set :rvm_bin_path, "/usr/local/rvm/bin"
set :application, "railsbp rails proxy"
set :repository, "git://github.com/railsbp/rails-proxy.git"
set :scm, :git
Total: 2689 samples
803 29.9% 29.9% 803 29.9% garbage_collector
419 15.6% 45.4% 419 15.6% String#=~
189 7.0% 52.5% 189 7.0% Kernel#caller
153 5.7% 58.2% 153 5.7% Regexp#match
71 2.6% 60.8% 324 12.0% ActiveModel::AttributeMethods#match_attribute_method?
70 2.6% 63.4% 104 3.9% #<Module:0x007fcfb904b010>#_id
51 1.9% 65.3% 51 1.9% String#to_i
45 1.7% 67.0% 386 14.4% ActiveModel::AttributeMethods#respond_to?
37 1.4% 68.4% 983 36.6% ActiveRecord::Associations::AssociationProxy#method_missing
Total: 2253 samples
812 36.0% 36.0% 812 36.0% garbage_collector
192 8.5% 44.6% 192 8.5% Kernel#caller
160 7.1% 51.7% 160 7.1% Regexp#match
67 3.0% 54.6% 68 3.0% Hash#[]=
47 2.1% 56.7% 47 2.1% String#include?
40 1.8% 58.5% 340 15.1% ActiveModel::AttributeMethods#respond_to?
40 1.8% 60.3% 142 6.3% Bullet::Registry::Base#add
40 1.8% 62.1% 87 3.9% Enumerable#any?
39 1.7% 63.8% 283 12.6% ActiveModel::AttributeMethods#match_attribute_method?
@flyerhzm
flyerhzm / 0-readme.md
Created April 4, 2012 14:42 — forked from burke/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

require 'redis'
require 'benchmark'
# user system total real
# redis set 0.280000 0.170000 0.450000 ( 0.809112)
# redis get 0.290000 0.160000 0.450000 ( 0.806711)
# redis mset with 1000 0.070000 0.020000 0.090000 ( 0.148474)
# redis mget with 1000 0.080000 0.020000 0.100000 ( 0.142837)
# redis mset with 100 0.050000 0.000000 0.050000 ( 0.067859)
# redis mget with 100 0.050000 0.010000 0.060000 ( 0.063040)
# redis mset with 10 0.040000 0.000000 0.040000 ( 0.060200)
class trinidad {
$jruby_home = "/opt/jruby"
$trinidad_home = "/opt/trinidad"
package { jsvc :
ensure => present
}
exec { install_trinidad :
command => "jruby -S gem install trinidad -v 1.3.4",
@flyerhzm
flyerhzm / gist:3755702
Created September 20, 2012 12:50
torquebox-lite mvn install
➜ torquebox-lite git:(master) mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] TorqueBox Lite
[INFO] TorqueBox Lite Build Aggregator
[INFO] TorqueBox Lite Build Assembly
[INFO] TorqueBox Lite Gems Parent
[INFO] TorqueBox Lite Gem
@flyerhzm
flyerhzm / gist:3816526
Created October 2, 2012 05:56
ruby zip perf
require 'zip/zip'
GC::Profiler.enable
before_stats = ObjectSpace.count_objects
start = Time.now
Zip::ZipFile.open("test.zip", Zip::ZipFile::CREATE) do |z|
Dir["**/*"].each do |file|
z.add file, file
end
end
puts "Total time: #{Time.now - start}"
@flyerhzm
flyerhzm / gist:3816533
Created October 2, 2012 05:56
shell zip perf
GC::Profiler.enable
before_stats = ObjectSpace.count_objects
start = Time.now
files = Dir["**/*"].map { |file| file unless File.directory?(file) }
`zip test.zip #{files.join(" ")}`
puts "Total time: #{Time.now - start}"
after_stats = ObjectSpace.count_objects
puts "[GC Stats] #{before_stats[:FREE] - after_stats[:FREE]} new allocated objects."
# Total time: 0.349816