Sha256: 4d1719a76608c6c695c08a6107a786819cf8dc20719950b4e173762f897c9173

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'xampl_generated_code/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

  #<people pid=''
  #        xmlns="http://xampl.com/people">
  #    <person pid=''
  #            given-name=''
  #            surname=''
  #            email=''
  #            phone=''>
  #        <address pid=''
  #                 street-address=''
  #                 city=''
  #                 state=''
  #                 postal-code=''/>
  #    </person>
  #</people>

  10.times do

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

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

    first_person = people.first
    address = first_person.address.first

    start_at = Time.now

    people_at_address = Xampl.transaction("random-people") do
      Xampl.find_mentions_of(address)
    end

    done = Time.now
    puts "found #{ people_at_address.size } people at that address in: #{ done - start_at }, #{ people_at_address.size / (done - start_at) }/s"
#    people_at_address.each { | person | puts person.pp_xml }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hutch-xamplr-1.0.3 examples/random-people-shared-addresses/find-mentions.rb
hutch-xamplr-1.0.4 examples/random-people-shared-addresses/find-mentions.rb
hutch-xamplr-1.0.5 examples/random-people-shared-addresses/find-mentions.rb