Skip to content

Instantly share code, notes, and snippets.

@timuruski
Created November 6, 2010 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timuruski/665059 to your computer and use it in GitHub Desktop.
Save timuruski/665059 to your computer and use it in GitHub Desktop.
require 'logger'
require 'mongo_mapper'
MongoMapper.database = 'tmp'
class Foo
include MongoMapper::Document
key :id, Integer
end
Foo.collection.remove
forks = 4
a = 0
b = 650000 # 649976
forks.times do |i|
Kernel.fork do
log = Logger.new("/Users/#{`whoami`.strip}/tmp/log-#{i}.log")
count = (b-a) / forks
# puts "#{count * i} - #{count * i + count}"
c = ((count * i)..(count * i + count))
c.each do |n|
log.info n
Foo.create(:name => n)
end
end
end
Process.waitall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment