среда, 13 августа 2014 г.

Простое тестирование скорости сайта с ApacheBench

ab -n 2000 -c 10 http://country-coder.blogspot.ru/

Это выполнит 2000 HTTP GET запросов, обработка до 10 запросов одновременно, к указанному http://country-coder.blogspot.ru/

вот результат
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking country-coder.blogspot.ru (be patient)
Completed 200 requests
Completed 400 requests
Completed 600 requests
Completed 800 requests
Completed 1000 requests
Completed 1200 requests
Completed 1400 requests
Completed 1600 requests
Completed 1800 requests
Completed 2000 requests
Finished 2000 requests


Server Software:        GSE
Server Hostname:        country-coder.blogspot.ru
Server Port:            80

Document Path:          /
Document Length:        208432 bytes

Concurrency Level:      10
Time taken for tests:   65.455 seconds
Complete requests:      2000
Failed requests:        1202
   (Connect: 0, Receive: 0, Length: 1202, Exceptions: 0)
Write errors:           0
Non-2xx responses:      1202
Total transferred:      167209285 bytes
HTML transferred:       166522258 bytes
Requests per second:    30.56 [#/sec] (mean)
Time per request:       327.275 [ms] (mean)
Time per request:       32.728 [ms] (mean, across all concurrent requests)
Transfer rate:          2494.69 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       24   30  12.7     28     523
Processing:   161  295 201.5    173    4255
Waiting:      161  191 138.4    173    4255
Total:        186  325 203.6    205    4280

Percentage of the requests served within a certain time (ms)
  50%    205
  66%    400
  75%    453
  80%    468
  90%    527
  95%    636
  98%    679
  99%    911
 100%   4280 (longest request)


пятница, 8 августа 2014 г.

Хорошая мотивация для перехода на rails


Хорошая мотивация для перехода на rails, а для меня очередное подтверждение что я иду верной дорогой
кстати балбеков олег из тамбовской области

Rails как произвести вальвацию когда необходимо иметь одно из двух поле обязательно заполненым

я сделал так Решение не очень красивое но другой альтернативы я не нашел
class Clientsale < ActiveRecord::Base                                          
  attr_accessible :comment, :company_name, :dolznost, :email, :fio, :phone, :project_id, :url_name, :user_id
  #validates :email, email_format: { message: "Ошибка при вводе email", allow_nil: true, allow_empty: true }
  
  validates_each :email, :phone do |record, attr, value|
    record.errors.add(attr, 'Хотя бы один контакт должен быть указан') if $test_clientsale_00163563213_find_me_in_def_contact_test.empty?
  end
  validates_each :company_name, :url_name  do |record, attr, value|
     record.errors.add(attr, 'Хотя бы один параметр (Адрес сайта или Название компании) ') if $test_url_and_name_company_56456456__find_me_in_def_contact_test.empty?
  end

  before_validation :contact_test
  before_save :set_user_project

  private
  def contact_test
    $test_clientsale_00163563213_find_me_in_def_contact_test = self.phone.to_s + self.email.to_s
    $test_url_and_name_company_56456456__find_me_in_def_contact_test = self.company_name.to_s + self.url_name.to_s                                                                     
  end
 
  def set_user_project
   self.user_id = User.current.id
   project = Project.new
   project.name = "text"                                              
   project.identifier = "project" + generate_sufix
   self.project_id = project.id if project.save
  end
  
  def generate_sufix
     Time.new.to_i.to_s + Random.new.rand(1_000_000..9_999_999).to_s
  end

end

вторник, 5 августа 2014 г.

casperjs пишем функциональные тесты для проверки title на страницах

Я мечтаю что когда нибудь перейду на TDD/BDD и понемногу иду в эту сторону.
итак ближе к делу возникла необходимость прописать SEO титлы. Для проверки я написал тест для casperjs(http://casperjs.org/) вот пример подобного теста для моего блога
casper.test.begin('Тест title на /2014/07/redmine_30.html', 1, function suite(test) {
    casper.start("http://country-coder.blogspot.ru/2014/07/redmine_30.html", function() {
        test.assertTitle("Блог сельского программиста: откат миграций для плагинов redmine", "ОК");
    });
    casper.run(function() {
        test.done();
    });
});

casper.test.begin('Тест title на /2014/07/redmine_25.html', 1, function suite(test) {
    casper.start("http://country-coder.blogspot.ru/2014/07/redmine_25.html", function() {
        test.assertTitle("Блог сельского программиста: redmine ошибка в хроме", "ОК");
    });
    casper.run(function() {
        test.done();
    });
});

casper.test.begin('Тест title на /2014/07/redmine.html', 1, function suite(test) {
    casper.start("http://country-coder.blogspot.ru/2014/07/redmine.html", function() {
        test.assertTitle("Блог сельского программиста: написание плагинов для redmine перевод", "ОК");
    });
    casper.run(function() {
        test.done();
    });
});
Запускаем casperjs test t_blog.js соответственно

PHP: The Right Way блог програмышки
Яндекс.Метрика