To edit pages or tickets please login with username/password: aaf/aaf

Changeset 275

Show
Ignore:
Timestamp:
11/18/07 12:41:01 (11 months ago)
Author:
jk
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/demo/app/models/stats.rb

    r271 r275  
    11class Stats < ActiveRecord::Base 
     2  def self.compute(kind) 
     3    start_date = minimum :created_at 
     4    sql = <<-END 
     5  select min(processing_time), max(processing_time), avg(processing_time), stddev(processing_time),  
     6         concat_ws(':', hour(timediff(created_at, ?)), lpad(minute(timediff(created_at, ?)), 2, '0')) as time, 
     7         group_concat(processing_time) as data 
     8      from stats  
     9      where kind=? group by time; 
     10  END 
     11    result = connection.execute sanitize_sql([sql, start_date, start_date, kind.to_s]) 
     12    returning [] do |res| 
     13      while row = result.fetch_row 
     14        data = row.last.split(',').map{|t|t.to_i} 
     15        median = data.size.odd? ? data[data.size/2] : ((data[data.size/2-1]+data[data.size/2]) / 2.0) 
     16        res << { :min => row[0].to_f, :max => row[1].to_f, :avg => row[2].to_f, :stddev => row[3].to_f, :time => row[4], :median => median } 
     17      end 
     18    end 
     19  end 
    220end 
  • trunk/demo/test/smoke/drb_smoke_test.rb

    r274 r275  
    1010module DrbSmokeTest 
    1111 
    12   RECORDS_PER_PROCESS = 10000 
     12  RECORDS_PER_PROCESS = 100000 
    1313  NUM_PROCESSES       = 10 # should be an even number 
    14   NUM_RECORDS_PER_LOGENTRY = 100 
     14  NUM_RECORDS_PER_LOGENTRY = 10 
    1515  NUM_DOCS = 50 
    16   NUM_TERMS = 1000 
     16  NUM_TERMS = 600 
    1717 
    1818  TIME_FACTOR = 1000.to_f / NUM_RECORDS_PER_LOGENTRY 
     
    5353  end 
    5454 
    55   puts "built #{NUM_DOCS} documents with an avg. size of #{DOCUMENTS.join.size / NUM_DOCS} Byte." 
     55  puts "built #{NUM_DOCS} documents with an avg. size of #{DOCUMENTS.join.size / NUM_DOCS} Bytes." 
    5656 
    5757  class Monitor 
     
    9797          Content.create! :title => "record #{@id} / #{i}", :description => DrbSmokeTest::random_document 
    9898        end 
    99         sleep 0.1 
     99        #sleep 0.1 
    100100        if i % NUM_RECORDS_PER_LOGENTRY == 0 
    101101          # write stats 
     
    108108      end 
    109109      Stats.create! :process_id => @id, :kind => 'finished' 
     110      puts "#{@i} finished" 
    110111    end 
    111112  end 
     
    114115    def run 
    115116      while Monitor::running? 
    116         result = nil 
    117         time = benchmark do 
    118           result = Content.find_with_ferret 'findme', :lazy => true 
     117        # search with concurrent writes 
     118          do_search 
     119      end 
     120      t = Time.now 
     121      while (Time.now - t) < 5.minutes 
     122        # the writers have finished, now hammer the server with searches for another 5 minutes 
     123        do_search 
     124      end 
     125      puts "#{@i} finished" 
     126    end 
     127 
     128    # run a search and log it's results. 
     129    # Search is done with a query consisting of the term 'findme'  
     130    # (which is guaranteed to yield 20 results) and a random term from  
     131    # the word list, ORed together 
     132    def do_search 
     133      hits = 0 
     134      time = benchmark do 
     135        NUM_RECORDS_PER_LOGENTRY.times do 
     136          result = Content.find_id_by_contents "findme OR #{WORDS.random_word}" 
     137          hits += result.first 
    119138        end 
    120         Stats.create! :process_id => @id, :kind => 'search', :info => "total_hits: #{result.total_hits} ; results: #{result.size}",  
    121                       :processing_time => time * 1000, 
    122                       :open_connections => Monitor::count_connections 
    123         sleep 1 
    124139      end 
     140      Stats.create! :process_id => @id, :kind => 'search', :info => "avg total_hits: #{hits/NUM_RECORDS_PER_LOGENTRY.to_f}",  
     141                    :processing_time => time * TIME_FACTOR, 
     142                    :open_connections => Monitor::count_connections 
    125143    end 
    126144 

To edit pages or tickets please login with username/password: aaf/aaf