267942571862781dd912de6482a35f46

second of three, not as fast as ActiveRecord - why?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'rubygems'
require 'sequel'
require 'benchmark'

# set up Sequel
Sequel::Model.db = DB = Sequel.sqlite('perf_sequel.db')

class SequelItem < Sequel::Model(:items)
  set_schema do
    primary_key :id
    varchar :name
    text :description
    boolean :active
    timestamp :created_at
  end
end

# create schema and populate
SequelItem.create_table!

1000.times do |i|
  DB[:items].insert(:name => "record_#{i}", :description => "test record", :active => i.remainder(3).zero?, :created_at => Time.now)
end

# run benchmarks
Benchmark.bmbm do |x|
  
  x.report('sequel single-thread') do
    100.times do
      SequelItem.where(:active => false).all
    end
  end
  
  x.report('sequel threaded') do
    threads = []
    10.times do
      t = Thread.new do
        10.times do
          SequelItem.where(:active => false).all
        end
      end
      threads.push(t)
    end
    threads.each { |t| t.join }
  end
  
end

SequelItem.drop_table

Refactorings

No refactoring yet !

E79ad0263bd0a2a51db5b5f9bc949941

cheapdomain

December 24, 2008, December 24, 2008 06:16, permalink

No rating. Login to rate!

Nowadays many companys are providing domain registration promotion.

I donot know which site is providing cheapest domain registration price. I need to register 100-1000 domains now.

Who can give me some great advice? Thanks for your help. Best Regards.

Your refactoring





Format Copy from initial code

or Cancel