From 40ef4b6907b286a1ffa5535e90860e3b3a8efc65 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Aug 2013 16:35:57 +1000 Subject: [PATCH] add time it takes to load rails --- script/bench.rb | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/script/bench.rb b/script/bench.rb index 3eb44bb76..ac3be2f36 100644 --- a/script/bench.rb +++ b/script/bench.rb @@ -1,10 +1,19 @@ require "socket" require "csv" +require "yaml" + +@timings = {} def run(command) system(command, out: $stdout, err: :out) end +def measure(name) + start = Time.now + yield + @timings[name] = ((Time.now - start) * 1000).to_i +end + def prereqs puts "Be sure to following packages are installed: @@ -41,7 +50,13 @@ unless File.exists?("config/redis.yml") `cp config/redis.yml.sample config/redis.yml` end +# Github settings ENV["RAILS_ENV"] = "profile" +ENV["RUBY_GC_MALLOC_LIMIT"] = "1000000000" +ENV["RUBY_HEAP_SLOTS_GROWTH_FACTOR"] = "1.25" +ENV["RUBY_HEAP_MIN_SLOTS"] = "800000" +ENV["RUBY_FREE_MIN"] = "600000" + def port_available? port server = TCPServer.open port @@ -62,17 +77,13 @@ puts `bundle exec rake db:create` `bundle exec rake db:migrate` puts "Loading Rails" -require File.expand_path(File.dirname(__FILE__) + "/../config/environment") +measure("load_rails") do + `bundle exec rake middleware` +end begin - unless pid = fork - require "rack" - Rack::Server.start(:config => "config.ru", - :AccessLog => [], - :Port => port) - exit - end + pid = spawn("bundle exec thin start -p #{port}") while port_available? port sleep 1 @@ -91,7 +102,8 @@ begin puts "Your Results:" puts({ - "home_page" => percentiles + "home_page" => percentiles, + "timings" => @timings }.to_yaml) ensure