import time from storage.relations import RelationStorage from cpsskins.relations import TestRelate as Relate from cpsskins.relations import Predicate, TriadicRelation storage = RelationStorage() precision = 10 def perf_1(n): predicate = Predicate('_ as portlet _ from perspective _ ') # create 100000 portlets in a same slot from 100000 different perspectives slot= Relate('main slot') for v in range(n): portlet = Relate('portlet %s' % str(v)) perspective = Relate('perspective %s' % str(v)) storage[str(v+n)] = TriadicRelation(predicate, slot, portlet, perspective) # get the list of portlets in the slot t1 = time.clock() # START for count in range(precision * 1000): a = storage.search(predicate=predicate, second=portlet) t2 = time.clock() # STOP print '%s, %s ms, %s' % ( len(storage), str(round((t2-t1)/precision, 4)), len(storage._relates) ) if __name__ == '__main__': perf_1(1) perf_1(9) perf_1(90) perf_1(900) perf_1(9000) perf_1(90000)