GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Motto-mysql is a complementary library to enhance and make faster 'mysql-ruby' library.
Clone URL: git://github.com/kwatch/motto-mysql.git
Update benchmark scripts.
kwatch (author)
Sun Oct 05 15:40:23 -0700 2008
commit  8ba9b2e66a9d01836b895f54856ff12f00bb8b1d
tree    d81a6db7d7dd8a9543eb9f22827881f22f31efa3
parent  05125d09574ebb2cb4d02b2f2c94033ec9c02cd4
...
41
42
43
44
45
46
 
 
 
47
48
49
50
51
52
53
54
55
56
 
 
 
 
 
 
 
 
57
58
59
...
63
64
65
66
67
 
68
69
70
...
82
83
84
85
86
87
88
89
90
91
92
 
 
 
 
 
 
 
 
93
94
95
...
195
196
197
198
199
200
 
 
 
201
202
203
...
41
42
43
 
 
 
44
45
46
47
48
 
 
 
 
 
 
 
 
49
50
51
52
53
54
55
56
57
58
59
...
63
64
65
 
 
66
67
68
69
...
81
82
83
 
 
 
 
 
 
 
 
84
85
86
87
88
89
90
91
92
93
94
...
194
195
196
 
 
 
197
198
199
200
201
202
0
@@ -41,19 +41,19 @@ def bench1(ntimes, conn, sql)
0
            'list=[]; rs.each{|row| }',
0
            'list=[]; rs.each{|row| list << row}',
0
            'list=[]; rs.each{|row| list<<Stock1.new(*row)}',
0
- #'list=[]; record.each {|row| list << Stock1.new(row) }',
0
- #'list=[]; for row in rs do list << Stock1.new(*row) end',
0
- #'list=rs.collect {|row| StockInfo.new(*row) }',
0
+ #'list=[]; record.each {|row| arr << Stock1.new(row) }',
0
+ #'list=[]; for row in rs do arr << Stock1.new(*row) end',
0
+ #'arr=rs.collect {|row| StockInfo.new(*row) }',
0
            'list=[]; rs.each_hash{|hash| list << hash}',
0
            'list=[]; rs.each_hash{|h| list<<Stock2.new(h)}',
0
- 'list = rs.fetch_all_hash()',
0
- 'list = rs.fetch_all_array()',
0
- 'list = rs.fetch_all_object(Stock0)',
0
- 'list=[]; rs.fetch_all_hash{|hash| list << hash}',
0
- 'list=[]; rs.fetch_all_array{|arr| list << arr}',
0
- 'list=[]; rs.fetch_all_object(Stock0){|o|list<<o}',
0
- 'list=[]; rs.fetch_all_hash{|h|list<<Stock2.new(h)}',
0
- 'list=[]; rs.fetch_all_array{|a|list<<Stock1.new(*a)}',
0
+ 'list = rs.fetch_all_as_hashes()',
0
+ 'list = rs.fetch_all_as_arrays()',
0
+ 'list = rs.fetch_all_as(Stock0)',
0
+ 'list=[]; rs.fetch_all_as_hashes{|h| list << h}',
0
+ 'list=[]; rs.fetch_all_as_arrays{|a| list << a}',
0
+ 'list=[]; rs.fetch_all_as(Stock0){|o| list << o}',
0
+ 'list=[]; rs.fetch_all_as_hashes{|h| list<<Stock2.new(h) }',
0
+ 'list=[]; rs.fetch_all_as_arrays{|a| list<<Stock1.new(*a)}',
0
   ]
0
   init_benchmark()
0
   puts "*** ntimes=#{ntimes}"
0
@@ -63,8 +63,7 @@ def bench1(ntimes, conn, sql)
0
       eval <<-END
0
         job.report('#{code}') do
0
           ntimes.times do
0
- result = conn.query(sql)
0
- rs = result
0
+ rs = conn.query(sql) # Mysql::Result
0
             #{code}
0
           end
0
         end
0
@@ -82,14 +81,14 @@ def bench2(ntimes, conn, sql)
0
            'lst=[]; st.each{|row| lst<<row}',
0
            'lst=[]; st.fetch{|row| lst<<row}',
0
            'lst=[]; st.each{|row| lst<<Stock1.new(row)}',
0
- 'lst = st.fetch_all_hash',
0
- 'lst = st.fetch_all_array',
0
- 'lst = st.fetch_all_object(Stock0)',
0
- 'lst=[]; st.fetch_all_hash{|hash| lst<<hash}',
0
- 'lst=[]; st.fetch_all_array{|arr| lst<<arr}',
0
- 'lst=[]; st.fetch_all_object(Stock0){|o|lst<<o}',
0
- 'lst=[]; st.fetch_all_hash{|h|lst<<Stock1.new(h)}',
0
- 'lst=[]; st.fetch_all_array{|a|lst<<Stock1.new(*a)}',
0
+ 'lst = st.fetch_all_as_hashes',
0
+ 'lst = st.fetch_all_as_arrays',
0
+ 'lst = st.fetch_all_as(Stock0)',
0
+ 'lst=[]; st.fetch_all_as_hashes{|h| lst<<h}',
0
+ 'lst=[]; st.fetch_all_as_arrays{|a| lst<<a}',
0
+ 'lst=[]; st.fetch_all_as(Stock0){|o|lst<<o}',
0
+ 'lst=[]; st.fetch_all_as_hashes{|h| lst<<Stock1.new(h)}',
0
+ 'lst=[]; st.fetch_all_as_arrays{|a| lst<<Stock1.new(*a)}',
0
   ]
0
   init_benchmark
0
   puts "*** ntimes=#{ntimes}"
0
@@ -195,9 +194,9 @@ def bench3(ntimes, conn, sql)
0
     # stocks << StockInfo.new(hash)
0
     #end
0
 
0
- #list = result.fetch_all_hash() # 10.6
0
- #list = result.fetch_all_array() # 9.2
0
- list = result.fetch_all_object(Stock0) # 10.5
0
+ #list = result.fetch_all_as_hashes() # 10.6
0
+ #list = result.fetch_all_as_arrays() # 9.2
0
+ list = result.fetch_all_as(Stock0) # 10.5
0
     #list.each do |e| p e end
0
   end
0
 end
...
61
62
63
64
 
65
66
67
 
68
69
70
...
61
62
63
 
64
65
 
 
66
67
68
69
0
@@ -61,10 +61,9 @@ $N.to_i.times do
0
 
0
   #list = stmt.collect {|row| list << row} #
0
 
0
- list = stmt.fetch_all_rows # 10.1 /
0
+ list = stmt.fetch_all_as_arrays # 10.1 /
0
 
0
- #list = stmt.fetch_all_hash() # 11.6 /
0
- #list = stmt.fetch_all_hashes2()
0
+ #list = stmt.fetch_all_hashes() # 11.6 /
0
   #list.each {|item| p item}
0
 
0
   #list = [] # 12.3 /

Comments

    No one has commented yet.