Sha256: fb9925273eff5b26fcd7bbc5958a8b9bd3e492df1a4202b4e65950a69fdd8f2c

Contents?: true

Size: 731 Bytes

Versions: 3

Compression:

Stored size: 731 Bytes

Contents

#!/usr/bin/ruby
require "#{File.dirname($0)}/../smart"
require 'time'

nums = 100000
# Watch the power

id      = 16
e_matnr = "9906264"
e_name  = "mangler"
e_secid = 1
exam    = true

p = []
0.upto(nums) do |i|
  p[i] = Thread.new do
    XML::Smart.modify("concurrent.xml","<solutions/>") do |xml|
      res = xml.find("/solutions/solution[@matnr=\"#{e_matnr}\" or @secid=\"#{e_secid}\"]").delete_all! if exam
      node = xml.root.add("solution",{:matnr => e_matnr, :name => e_name, :secid => e_secid, :when => Time.now.xmlschema, :assessment => id})
      1.upto(3) do |qbi|
        qid = qbi*2
        ques = node.add("question", :block => qbi, :question => qid)
      end  
    end  
  end  
end

p.each do |t|
  t.join
end  

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-xml-smart-0.1.12.1-i486-linux examples/concurrent.rb
ruby-xml-smart-0.1.12-i486-linux examples/concurrent.rb
ruby-xml-smart-0.1.11-i486-linux examples/concurrent.rb