755 self.info('more relations: %.2gs', (t2-t1)) |
755 self.info('more relations: %.2gs', (t2-t1)) |
756 req.cnx.commit() |
756 req.cnx.commit() |
757 t3 = time.time() |
757 t3 = time.time() |
758 self.info('commit creation: %.2gs', (t3 - t2)) |
758 self.info('commit creation: %.2gs', (t3 - t2)) |
759 |
759 |
|
760 |
|
761 def test_session_add_relation(self): |
|
762 """ to be compared with test_session_add_relations""" |
|
763 req = self.request() |
|
764 personnes = [] |
|
765 for i in xrange(2000): |
|
766 p = req.create_entity('Personne', nom=u'Doe%03d'%i, prenom=u'John', sexe=u'M') |
|
767 personnes.append(p) |
|
768 abraham = req.create_entity('Personne', nom=u'Abraham', prenom=u'John', sexe=u'M') |
|
769 req.cnx.commit() |
|
770 t0 = time.time() |
|
771 add_relation = self.session.add_relation |
|
772 for p in personnes: |
|
773 add_relation(abraham.eid, 'personne_composite', p.eid) |
|
774 req.cnx.commit() |
|
775 t1 = time.time() |
|
776 self.info('add relation: %.2gs', t1-t0) |
|
777 |
|
778 def test_session_add_relations (self): |
|
779 """ to be compared with test_session_add_relation""" |
|
780 req = self.request() |
|
781 personnes = [] |
|
782 for i in xrange(2000): |
|
783 p = req.create_entity('Personne', nom=u'Doe%03d'%i, prenom=u'John', sexe=u'M') |
|
784 personnes.append(p) |
|
785 abraham = req.create_entity('Personne', nom=u'Abraham', prenom=u'John', sexe=u'M') |
|
786 req.cnx.commit() |
|
787 t0 = time.time() |
|
788 add_relations = self.session.add_relations |
|
789 relations = [('personne_composite', [(abraham.eid, p.eid) for p in personnes])] |
|
790 add_relations(relations) |
|
791 req.cnx.commit() |
|
792 t1 = time.time() |
|
793 self.info('add relations: %.2gs', t1-t0) |
|
794 def test_session_add_relation_inlined(self): |
|
795 """ to be compared with test_session_add_relations""" |
|
796 req = self.request() |
|
797 personnes = [] |
|
798 for i in xrange(2000): |
|
799 p = req.create_entity('Personne', nom=u'Doe%03d'%i, prenom=u'John', sexe=u'M') |
|
800 personnes.append(p) |
|
801 abraham = req.create_entity('Personne', nom=u'Abraham', prenom=u'John', sexe=u'M') |
|
802 req.cnx.commit() |
|
803 t0 = time.time() |
|
804 add_relation = self.session.add_relation |
|
805 for p in personnes: |
|
806 add_relation(abraham.eid, 'personne_inlined', p.eid) |
|
807 req.cnx.commit() |
|
808 t1 = time.time() |
|
809 self.info('add relation (inlined): %.2gs', t1-t0) |
|
810 |
|
811 def test_session_add_relations_inlined (self): |
|
812 """ to be compared with test_session_add_relation""" |
|
813 req = self.request() |
|
814 personnes = [] |
|
815 for i in xrange(2000): |
|
816 p = req.create_entity('Personne', nom=u'Doe%03d'%i, prenom=u'John', sexe=u'M') |
|
817 personnes.append(p) |
|
818 abraham = req.create_entity('Personne', nom=u'Abraham', prenom=u'John', sexe=u'M') |
|
819 req.cnx.commit() |
|
820 t0 = time.time() |
|
821 add_relations = self.session.add_relations |
|
822 relations = [('personne_inlined', [(abraham.eid, p.eid) for p in personnes])] |
|
823 add_relations(relations) |
|
824 req.cnx.commit() |
|
825 t1 = time.time() |
|
826 self.info('add relations (inlined): %.2gs', t1-t0) |
|
827 |
760 if __name__ == '__main__': |
828 if __name__ == '__main__': |
761 unittest_main() |
829 unittest_main() |