File: sequel.rb

package info (click to toggle)
ruby-mysql2 0.5.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: ansic: 3,459; ruby: 3,334; sh: 226; makefile: 3
file content (31 lines) | stat: -rw-r--r-- 791 bytes parent folder | download | duplicates (3)
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
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rubygems'
require 'benchmark/ips'
require 'mysql2'
require 'sequel'
require 'sequel/adapters/do'

mysql2_opts = "mysql2://root@localhost/test"
mysql_opts = "mysql://root@localhost/test"
do_mysql_opts = "do:mysql://root@localhost/test"

class Mysql2Model < Sequel::Model(Sequel.connect(mysql2_opts)[:mysql2_test]); end
class MysqlModel < Sequel::Model(Sequel.connect(mysql_opts)[:mysql2_test]); end
class DOMysqlModel < Sequel::Model(Sequel.connect(do_mysql_opts)[:mysql2_test]); end

Benchmark.ips do |x|
  x.report "Mysql2" do
    Mysql2Model.limit(1000).all
  end

  x.report "do:mysql" do
    DOMysqlModel.limit(1000).all
  end

  x.report "Mysql" do
    MysqlModel.limit(1000).all
  end

  x.compare!
end