mysql2 0.2.19b4 → 0.2.19b5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- bin/
2
- Makefile
3
- *.dSYM
4
- *.o
5
- *.bundle
6
- *.so
7
- *.a
8
- *.rbc
9
- mkmf.log
10
- pkg/
11
- tmp
12
- vendor
13
- lib/mysql2/mysql2.rb
14
- spec/configuration.yml
@@ -1 +0,0 @@
1
- 1.9.3
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --colour
3
- --fail-fast
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.3@mysql2 --create
@@ -1,7 +0,0 @@
1
- rvm:
2
- - 1.8.7
3
- - 1.9.2
4
- - 1.9.3
5
- - ree
6
- before_script:
7
- - "mysql -e 'create database test;' >/dev/null"
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source :rubygems
2
-
3
- gemspec
@@ -1,61 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mysql2 (0.2.19b4)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- activemodel (3.2.1)
10
- activesupport (= 3.2.1)
11
- builder (~> 3.0.0)
12
- activerecord (3.2.1)
13
- activemodel (= 3.2.1)
14
- activesupport (= 3.2.1)
15
- arel (~> 3.0.0)
16
- tzinfo (~> 0.3.29)
17
- activesupport (3.2.1)
18
- i18n (~> 0.6)
19
- multi_json (~> 1.0)
20
- addressable (2.2.6)
21
- arel (3.0.0)
22
- builder (3.0.0)
23
- data_objects (0.10.8)
24
- addressable (~> 2.1)
25
- diff-lcs (1.1.3)
26
- do_mysql (0.10.8)
27
- data_objects (= 0.10.8)
28
- eventmachine (0.12.10)
29
- faker (1.0.1)
30
- i18n (~> 0.4)
31
- i18n (0.6.0)
32
- multi_json (1.0.4)
33
- mysql (2.8.1)
34
- rake (0.8.7)
35
- rake-compiler (0.7.9)
36
- rake
37
- rspec (2.8.0)
38
- rspec-core (~> 2.8.0)
39
- rspec-expectations (~> 2.8.0)
40
- rspec-mocks (~> 2.8.0)
41
- rspec-core (2.8.0)
42
- rspec-expectations (2.8.0)
43
- diff-lcs (~> 1.1.2)
44
- rspec-mocks (2.8.0)
45
- sequel (3.32.0)
46
- tzinfo (0.3.31)
47
-
48
- PLATFORMS
49
- ruby
50
-
51
- DEPENDENCIES
52
- activerecord
53
- do_mysql
54
- eventmachine
55
- faker
56
- mysql
57
- mysql2!
58
- rake (= 0.8.7)
59
- rake-compiler (~> 0.7.7)
60
- rspec
61
- sequel
data/Rakefile DELETED
@@ -1,5 +0,0 @@
1
- # encoding: UTF-8
2
- require 'rake'
3
-
4
- # Load custom tasks
5
- Dir['tasks/*.rake'].sort.each { |f| load f }
@@ -1,51 +0,0 @@
1
- # encoding: UTF-8
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
-
4
- require 'rubygems'
5
- require 'benchmark'
6
- require 'active_record'
7
-
8
- ActiveRecord::Base.default_timezone = :local
9
- ActiveRecord::Base.time_zone_aware_attributes = true
10
-
11
- number_of = 10
12
- mysql2_opts = {
13
- :adapter => 'mysql2',
14
- :database => 'test'
15
- }
16
- mysql_opts = {
17
- :adapter => 'mysql',
18
- :database => 'test'
19
- }
20
-
21
- class Mysql2Model < ActiveRecord::Base
22
- set_table_name :mysql2_test
23
- end
24
-
25
- class MysqlModel < ActiveRecord::Base
26
- set_table_name :mysql2_test
27
- end
28
-
29
- Benchmark.bmbm do |x|
30
- x.report "Mysql2" do
31
- Mysql2Model.establish_connection(mysql2_opts)
32
- number_of.times do
33
- Mysql2Model.all(:limit => 1000).each{ |r|
34
- r.attributes.keys.each{ |k|
35
- r.send(k.to_sym)
36
- }
37
- }
38
- end
39
- end
40
-
41
- x.report "Mysql" do
42
- MysqlModel.establish_connection(mysql_opts)
43
- number_of.times do
44
- MysqlModel.all(:limit => 1000).each{ |r|
45
- r.attributes.keys.each{ |k|
46
- r.send(k.to_sym)
47
- }
48
- }
49
- end
50
- end
51
- end
@@ -1,42 +0,0 @@
1
- # encoding: UTF-8
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
-
4
- require 'rubygems'
5
- require 'benchmark'
6
- require 'active_record'
7
-
8
- times = 25
9
-
10
-
11
- # mysql2
12
- mysql2_opts = {
13
- :adapter => 'mysql2',
14
- :database => 'test',
15
- :pool => times
16
- }
17
- ActiveRecord::Base.establish_connection(mysql2_opts)
18
- x = Benchmark.realtime do
19
- threads = []
20
- times.times do
21
- threads << Thread.new { ActiveRecord::Base.connection.execute("select sleep(1)") }
22
- end
23
- threads.each {|t| t.join }
24
- end
25
- puts "mysql2: #{x} seconds"
26
-
27
-
28
- # mysql
29
- mysql2_opts = {
30
- :adapter => 'mysql',
31
- :database => 'test',
32
- :pool => times
33
- }
34
- ActiveRecord::Base.establish_connection(mysql2_opts)
35
- x = Benchmark.realtime do
36
- threads = []
37
- times.times do
38
- threads << Thread.new { ActiveRecord::Base.connection.execute("select sleep(1)") }
39
- end
40
- threads.each {|t| t.join }
41
- end
42
- puts "mysql: #{x} seconds"
@@ -1,33 +0,0 @@
1
- # encoding: UTF-8
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
-
4
- raise Mysql2::Mysql2Error.new("GC allocation benchmarks only supported on Ruby 1.9!") unless RUBY_VERSION =~ /1\.9/
5
-
6
- require 'rubygems'
7
- require 'benchmark'
8
- require 'active_record'
9
-
10
- ActiveRecord::Base.default_timezone = :local
11
- ActiveRecord::Base.time_zone_aware_attributes = true
12
-
13
- class Mysql2Model < ActiveRecord::Base
14
- set_table_name :mysql2_test
15
- end
16
-
17
- def bench_allocations(feature, iterations = 10, &blk)
18
- puts "GC overhead for #{feature}"
19
- Mysql2Model.establish_connection(:adapter => 'mysql2', :database => 'test')
20
- GC::Profiler.clear
21
- GC::Profiler.enable
22
- iterations.times{ blk.call }
23
- GC::Profiler.report(STDOUT)
24
- GC::Profiler.disable
25
- end
26
-
27
- bench_allocations('coercion') do
28
- Mysql2Model.all(:limit => 1000).each{ |r|
29
- r.attributes.keys.each{ |k|
30
- r.send(k.to_sym)
31
- }
32
- }
33
- end
@@ -1,36 +0,0 @@
1
- # encoding: UTF-8
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
-
4
- require 'rubygems'
5
- require 'benchmark'
6
- require 'mysql'
7
- require 'mysql2'
8
- require 'do_mysql'
9
-
10
- def run_escape_benchmarks(str, number_of = 1000)
11
- Benchmark.bmbm do |x|
12
- mysql = Mysql.new("localhost", "root")
13
- x.report "Mysql #{str.inspect}" do
14
- number_of.times do
15
- mysql.quote str
16
- end
17
- end
18
-
19
- mysql2 = Mysql2::Client.new(:host => "localhost", :username => "root")
20
- x.report "Mysql2 #{str.inspect}" do
21
- number_of.times do
22
- mysql2.escape str
23
- end
24
- end
25
-
26
- do_mysql = DataObjects::Connection.new("mysql://localhost/test")
27
- x.report "do_mysql #{str.inspect}" do
28
- number_of.times do
29
- do_mysql.quote_string str
30
- end
31
- end
32
- end
33
- end
34
-
35
- run_escape_benchmarks "abc'def\"ghi\0jkl%mno"
36
- run_escape_benchmarks "clean string"
@@ -1,80 +0,0 @@
1
- # encoding: UTF-8
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
-
4
- require 'rubygems'
5
- require 'benchmark'
6
- require 'mysql'
7
- require 'mysql2'
8
- require 'do_mysql'
9
-
10
- number_of = 100
11
- database = 'test'
12
- sql = "SELECT * FROM mysql2_test LIMIT 100"
13
-
14
- class Mysql
15
- include Enumerable
16
- end
17
-
18
- def mysql_cast(type, value)
19
- case type
20
- when Mysql::Field::TYPE_NULL
21
- nil
22
- when Mysql::Field::TYPE_TINY, Mysql::Field::TYPE_SHORT, Mysql::Field::TYPE_LONG,
23
- Mysql::Field::TYPE_INT24, Mysql::Field::TYPE_LONGLONG, Mysql::Field::TYPE_YEAR
24
- value.to_i
25
- when Mysql::Field::TYPE_DECIMAL, Mysql::Field::TYPE_NEWDECIMAL
26
- BigDecimal.new(value)
27
- when Mysql::Field::TYPE_DOUBLE, Mysql::Field::TYPE_FLOAT
28
- value.to_f
29
- when Mysql::Field::TYPE_DATE
30
- Date.parse(value)
31
- when Mysql::Field::TYPE_TIME, Mysql::Field::TYPE_DATETIME, Mysql::Field::TYPE_TIMESTAMP
32
- Time.parse(value)
33
- when Mysql::Field::TYPE_BLOB, Mysql::Field::TYPE_BIT, Mysql::Field::TYPE_STRING,
34
- Mysql::Field::TYPE_VAR_STRING, Mysql::Field::TYPE_CHAR, Mysql::Field::TYPE_SET
35
- Mysql::Field::TYPE_ENUM
36
- value
37
- else
38
- value
39
- end
40
- end
41
-
42
- Benchmark.bmbm do |x|
43
- mysql2 = Mysql2::Client.new(:host => "localhost", :username => "root")
44
- mysql2.query "USE #{database}"
45
- x.report "Mysql2" do
46
- number_of.times do
47
- mysql2_result = mysql2.query sql, :symbolize_keys => true
48
- mysql2_result.each do |res|
49
- # puts res.inspect
50
- end
51
- end
52
- end
53
-
54
- mysql = Mysql.new("localhost", "root")
55
- mysql.query "USE #{database}"
56
- x.report "Mysql" do
57
- number_of.times do
58
- mysql_result = mysql.query sql
59
- fields = mysql_result.fetch_fields
60
- mysql_result.each do |row|
61
- row_hash = {}
62
- row.each_with_index do |f, j|
63
- row_hash[fields[j].name.to_sym] = mysql_cast(fields[j].type, row[j])
64
- end
65
- # puts row_hash.inspect
66
- end
67
- end
68
- end
69
-
70
- do_mysql = DataObjects::Connection.new("mysql://localhost/#{database}")
71
- command = do_mysql.create_command sql
72
- x.report "do_mysql" do
73
- number_of.times do
74
- do_result = command.execute_reader
75
- do_result.each do |res|
76
- # puts res.inspect
77
- end
78
- end
79
- end
80
- end
@@ -1,56 +0,0 @@
1
- # encoding: UTF-8
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
-
4
- require 'rubygems'
5
- require 'benchmark'
6
- require 'mysql'
7
- require 'mysql2'
8
- require 'do_mysql'
9
-
10
- number_of = 100
11
- database = 'test'
12
- sql = "SELECT * FROM mysql2_test LIMIT 100"
13
-
14
- Benchmark.bmbm do |x|
15
- mysql2 = Mysql2::Client.new(:host => "localhost", :username => "root")
16
- mysql2.query "USE #{database}"
17
- x.report "Mysql2 (cast: true)" do
18
- number_of.times do
19
- mysql2_result = mysql2.query sql, :symbolize_keys => true, :cast => true
20
- mysql2_result.each do |res|
21
- # puts res.inspect
22
- end
23
- end
24
- end
25
-
26
- x.report "Mysql2 (cast: false)" do
27
- number_of.times do
28
- mysql2_result = mysql2.query sql, :symbolize_keys => true, :cast => false
29
- mysql2_result.each do |res|
30
- # puts res.inspect
31
- end
32
- end
33
- end
34
-
35
- mysql = Mysql.new("localhost", "root")
36
- mysql.query "USE #{database}"
37
- x.report "Mysql" do
38
- number_of.times do
39
- mysql_result = mysql.query sql
40
- mysql_result.each_hash do |res|
41
- # puts res.inspect
42
- end
43
- end
44
- end
45
-
46
- do_mysql = DataObjects::Connection.new("mysql://localhost/#{database}")
47
- command = DataObjects::Mysql::Command.new do_mysql, sql
48
- x.report "do_mysql" do
49
- number_of.times do
50
- do_result = command.execute_reader
51
- do_result.each do |res|
52
- # puts res.inspect
53
- end
54
- end
55
- end
56
- end
@@ -1,37 +0,0 @@
1
- # encoding: UTF-8
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
-
4
- require 'rubygems'
5
- require 'benchmark'
6
- require 'mysql2'
7
- require 'sequel'
8
- require 'sequel/adapters/do'
9
-
10
- number_of = 10
11
- mysql2_opts = "mysql2://localhost/test"
12
- mysql_opts = "mysql://localhost/test"
13
- do_mysql_opts = "do:mysql://localhost/test"
14
-
15
- class Mysql2Model < Sequel::Model(Sequel.connect(mysql2_opts)[:mysql2_test]); end
16
- class MysqlModel < Sequel::Model(Sequel.connect(mysql_opts)[:mysql2_test]); end
17
- class DOMysqlModel < Sequel::Model(Sequel.connect(do_mysql_opts)[:mysql2_test]); end
18
-
19
- Benchmark.bmbm do |x|
20
- x.report "Mysql2" do
21
- number_of.times do
22
- Mysql2Model.limit(1000).all
23
- end
24
- end
25
-
26
- x.report "do:mysql" do
27
- number_of.times do
28
- DOMysqlModel.limit(1000).all
29
- end
30
- end
31
-
32
- x.report "Mysql" do
33
- number_of.times do
34
- MysqlModel.limit(1000).all
35
- end
36
- end
37
- end