##Procfile:
- web: bundle exec thin -R config.ru start -p $PORT -e $RACK_ENV
- web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
- web: bundle exec puma -t 1:4 -b tcp://0.0.0.0:$PORT
##Benchmarks:
~ siege -c500 -t30s www.aijaberjoza.lv
##Procfile:
##Benchmarks:
~ siege -c500 -t30s www.aijaberjoza.lv
| require 'digest/md5' | |
| require 'benchmark' | |
| parts = [] | |
| body = ['Hello World'] | |
| Benchmark.bm do |x| | |
| x.report('each') do | |
| body.each { |part| parts << part } | |
| Digest::MD5.hexdigest(parts.join) |
###Бенчмарки Машина: Маc ОС Х 10.7.5, 2Ghz Core2Duo, 8Gb RAM
Тестировал средний проект командой:
time bundle exec rake routes
| Ruby version | Time |
|---|---|
| ruby-1.9.3-p125 | 11.85s |
| class PostsController < ApplicationController | |
| # GET /posts | |
| # GET /posts.json | |
| def index | |
| @posts = Post.all | |
| respond_to do |format| | |
| format.html # index.html.erb | |
| format.json { render json: @posts } | |
| end |
| # coding: utf-8 | |
| ClassCountry.create(name: "АФГАНИСТАН", full_name: "Переходное Исламское Государство Афганистан", number_code: "004", alfa2: "AF", alfa3: "AFG") | |
| ClassCountry.create(name: "АЛБАНИЯ", full_name: "Республика Албания", number_code: "008", alfa2: "AL", alfa3: "ALB") | |
| ClassCountry.create(name: "АНТАРКТИДА", full_name: nil, number_code: "010", alfa2: "AQ", alfa3: "ATA") | |
| ClassCountry.create(name: "АЛЖИР", full_name: "Алжирская Народная Демократическая Республика", number_code: "012", alfa2: "DZ", alfa3: "DZA") | |
| ClassCountry.create(name: "АМЕРИКАНСКОЕ САМОА", full_name: nil, number_code: "016", alfa2: "AS", alfa3: "ASM") | |
| ClassCountry.create(name: "АНДОРРА", full_name: "Княжество Андорра", number_code: "020", alfa2: "AD", alfa3: "AND") | |
| ClassCountry.create(name: "АНГОЛА", full_name: "Республика Ангола", number_code: "024", alfa2: "AO", alfa3: "AGO") | |
| ClassCountry.create(name: "АНТИГУА И БАРБУДА", full_name: nil, number_code: "028", alfa2: "AG", alfa3: "ATG") |
| def index | |
| q = params[:q] | |
| if q == "what is the sum of 8 and 22" | |
| rezult = "30" | |
| elsif q.include? "what is your name" | |
| rezult = "torbjon" | |
| elsif q.include? "I was here before. what is my name" | |
| rezult = Stuff.first.name | |
| elsif q.include? "want to shop. What products do you have for sale (comma separated)" | |
| rezult = "banana, apple" |
| # NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
| $ cd /usr/src | |
| $ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
| $ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
| $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
| $ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
| $ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
| /** | |
| * Modal window | |
| */ | |
| (function($) { | |
| var defaults = { | |
| url: false, | |
| opener: false, | |
| remote: true, | |
| content: '', | |
| data: {}, |
| set :asset_env, "RAILS_GROUPS=assets" | |
| set :asset_directory, 'public/assets' | |
| set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb) | |
| after 'deploy:update_code', 'deploy:assets' | |
| namespace :deploy do | |
| task :assets, :roles => :web, :except => { :no_release => true } do | |
| from = source.next_revision(current_revision) | |
| if capture("cd #{latest_release} && #{source.local.log(from)} #{assets_dependencies.join ' '} | wc -l").to_i > 0 |