Skip to content

Instantly share code, notes, and snippets.

@kostya kostya/.gitignore
Last active Dec 15, 2015

Embed
What would you like to do?
tt1
Gemfile.lock
source :rubygems
gem 'activerecord', '~>3.2'
gem 'pg'
require 'rubygems'
require 'bundler/setup'
require 'active_record'
conn = {:adapter => 'postgresql', :database => "tt_test", :pool => 30, :allow_concurrency => true}
`dropdb tt_test`
`createdb tt_test`
ActiveRecord::Base.establish_connection conn
ActiveRecord::Migration.create_table(:bla){|t| t.integer :a; t.string :b }
class Bla < ActiveRecord::Base; self.table_name = 'bla'; end
T = 10
N = 100
T.times do |i|
Bla.create! :a => i, :b => "bla#{i}"
end
tm1 = Time.now
(0...T).map do |i|
Thread.new do
bla = Bla.find_by_a(i)
bla.b = bla.b + "i"
bla.save!
end
end.each(&:join)
puts Time.now - tm1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.