mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
add time it takes to load rails
This commit is contained in:
parent
8f5866d9e8
commit
40ef4b6907
1 changed files with 21 additions and 9 deletions
|
@ -1,10 +1,19 @@
|
||||||
require "socket"
|
require "socket"
|
||||||
require "csv"
|
require "csv"
|
||||||
|
require "yaml"
|
||||||
|
|
||||||
|
@timings = {}
|
||||||
|
|
||||||
def run(command)
|
def run(command)
|
||||||
system(command, out: $stdout, err: :out)
|
system(command, out: $stdout, err: :out)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def measure(name)
|
||||||
|
start = Time.now
|
||||||
|
yield
|
||||||
|
@timings[name] = ((Time.now - start) * 1000).to_i
|
||||||
|
end
|
||||||
|
|
||||||
def prereqs
|
def prereqs
|
||||||
puts "Be sure to following packages are installed:
|
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`
|
`cp config/redis.yml.sample config/redis.yml`
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Github settings
|
||||||
ENV["RAILS_ENV"] = "profile"
|
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
|
def port_available? port
|
||||||
server = TCPServer.open port
|
server = TCPServer.open port
|
||||||
|
@ -62,17 +77,13 @@ puts `bundle exec rake db:create`
|
||||||
`bundle exec rake db:migrate`
|
`bundle exec rake db:migrate`
|
||||||
|
|
||||||
puts "Loading Rails"
|
puts "Loading Rails"
|
||||||
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
measure("load_rails") do
|
||||||
|
`bundle exec rake middleware`
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
unless pid = fork
|
pid = spawn("bundle exec thin start -p #{port}")
|
||||||
require "rack"
|
|
||||||
Rack::Server.start(:config => "config.ru",
|
|
||||||
:AccessLog => [],
|
|
||||||
:Port => port)
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
while port_available? port
|
while port_available? port
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -91,7 +102,8 @@ begin
|
||||||
puts "Your Results:"
|
puts "Your Results:"
|
||||||
|
|
||||||
puts({
|
puts({
|
||||||
"home_page" => percentiles
|
"home_page" => percentiles,
|
||||||
|
"timings" => @timings
|
||||||
}.to_yaml)
|
}.to_yaml)
|
||||||
|
|
||||||
ensure
|
ensure
|
||||||
|
|
Loading…
Reference in a new issue