Sha256: 7ce89230450da7f57cce2127124f0912703d25d3a5bd86caa0fa9e8e78920721

Contents?: true

Size: 2 KB

Versions: 3

Compression:

Stored size: 2 KB

Contents

$LOAD_PATH.unshift("xampl_generated_code")

require 'RandomPeople'
require 'people'

Xampl.set_default_persister_kind(:tokyo_cabinet)
#Xampl.set_default_persister_format(:xml_format)
Xampl.set_default_persister_format(:ruby_format)

module RandomPeople

  #GivenName,Surname,StreetAddress,City,State,ZipCode,EmailAddress,TelephoneNumber
  #<people pid='' xmlns="http://xampl.com/people">
  #    <person pid=''
  #            given-name=''
  #            surname=''
  #            street-address=''
  #            city=''
  #            state=''
  #            postal-code=''
  #            email=''
  #            phone=''/>
  #</people>

  5.times do
    found1 = []
    found2 = []
    found3 = []

    start_query_at = Time.now
#    found1 = Xampl.transaction("random-people") do
#      Xampl.query do | q |
#        q.add_condition('city', :equals, 'TORONTO')
#        q.add_condition('email', :ends_with, 'dodgit.com')
#
#        q.order_by('surname', :strasc)
#      end
#    end

    start_find_at = Time.now
    found2 = Xampl.transaction("random-people") do
      Xampl.find_xampl do | q |
        q.add_condition('city', :equals, 'TORONTO')
        q.add_condition('email', :ends_with, 'dodgit.com')

#        q.setlimit(10, 10)

        q.order_by('surname', :strasc)
      end
    end

    start_find_pids_at = Time.now

    found3 = Xampl.transaction("random-people") do
      Xampl.find_pids do | q |
        q.add_condition('city', :equals, 'TORONTO')
#        q.add_condition('email', :ends_with, 'dodgit.com')

#        q.setlimit(10, 10)

        q.order_by('surname', :strasc)
      end
    end
    done = Time.now

    #  found1.each do | person_meta |
    #    puts "surname: #{ person_meta['surname']}, given: #{ person_meta['xampl'].given_name }"
    #  end
    puts "found:: query #{ found1.size }, find_xampl: #{ found2.size }, find_pids: #{ found3.size }"
    puts "query in: #{ start_find_at - start_query_at }, find_xampl in: #{ start_find_pids_at - start_find_at }, pids in: #{ done - start_find_pids_at}\n"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hutch-xamplr-1.0.0 examples/random-people/query.rb
hutch-xamplr-1.0.1 examples/random-people/query.rb
hutch-xamplr-1.0.2 examples/random-people/query.rb