def generate_test_aol(): """Return an AOL list of Appendable (tuple) instances (encoding 2 ``OLDInstance``s). """ test_old_instance_1, err = domain.construct_old_instance( slug='oka', name='Okanagan OLD', url='http://127.0.0.1:5679/oka', leader='', state=domain.NOT_SYNCED_STATE, is_auto_syncing=False) test_old_instance_2, err = domain.construct_old_instance( slug='bla', name='Blackfoot OLD', url='http://127.0.0.1:5679/bla', leader='', state=domain.NOT_SYNCED_STATE, is_auto_syncing=False) test_old_instance_1_quads = aol_mod.instance_to_quads( test_old_instance_1, domain.OLD_INSTANCE_TYPE) test_old_instance_2_quads = aol_mod.instance_to_quads( test_old_instance_2, domain.OLD_INSTANCE_TYPE) aol = [] for quad in test_old_instance_1_quads + test_old_instance_2_quads: aol = aol_mod.append_to_aol(aol, quad) return aol
def test_large_aol_append_time(): """Question: How long does it take to append to a large AOL file on disk? >>> [('aol-size-1.txt', 0.00011014938354492188), ... ('aol-size-10.txt', 0.000102996826171875), ... ('aol-size-100.txt', 0.00010323524475097656), ... ('aol-size-1000.txt', 0.00010609626770019531), ... ('aol-size-10000.txt', 0.00010776519775390625), ... ('aol-size-100000.txt', 0.0001049041748046875), ... ('aol-size-1000000.txt', 0.000141143798828125)] """ fnames = sorted(fn for fn in os.listdir(utils.RESOURCES_PATH)) runs = [] for fn in fnames: aol_path = os.path.join(utils.RESOURCES_PATH, fn) aol = aol_mod.get_aol(aol_path) aol_to_add = utils.generate_large_test_aol(1) t1 = time.time() for quad in aol_to_add: aol = aol_mod.append_to_aol(aol, quad) t2 = time.time() tot_time = t2 - t1 runs.append((fn, tot_time)) pprint.pprint(runs)
def generate_large_test_aol(n_old_instances): """Return an AOL enxoding ``n_old_instances`` OLDInstances.""" aol = [] for _ in range(n_old_instances): test_old_instance, err = domain.construct_old_instance( slug='oka', name='Okanagan OLD', url='http://127.0.0.1:5679/oka', leader='', state=domain.NOT_SYNCED_STATE, is_auto_syncing=False) for quad in aol_mod.instance_to_quads( test_old_instance, domain.OLD_INSTANCE_TYPE): aol = aol_mod.append_to_aol(aol, quad) return aol
def generate_oi_quads(): """Return a list of quads representing a single OI, OLDInstance. """ old_instance, err = domain.construct_old_instance( slug='oka', name='Okanagan OLD', url='http://127.0.0.1:5679/oka', leader='', state=domain.NOT_SYNCED_STATE, is_auto_syncing=False) old_instance_quads = aol_mod.instance_to_quads( old_instance, domain.OLD_INSTANCE_TYPE) aol = [] for quad in old_instance_quads: aol = aol_mod.append_to_aol(aol, quad) return aol
def generate_test_aol(): """Return an AOL encoding 2 OLDInstances, 1 DativeApp and 1 OLDService """ old_instance_1, _ = domain.construct_old_instance( slug='oka', name='Okanagan OLD', url='http://127.0.0.1:5679/oka', leader='', state=domain.NOT_SYNCED_STATE, is_auto_syncing=False) old_instance_2, _ = domain.construct_old_instance( slug='bla', name='Blackfoot OLD', url='http://127.0.0.1:5679/bla', leader='', state=domain.NOT_SYNCED_STATE, is_auto_syncing=False) dative_app, _ = domain.construct_dative_app( url='http://127.0.0.1:5678/') old_service, _ = domain.construct_old_service( url='http://127.0.0.1:5679/') old_instance_1_quads = aol_mod.instance_to_quads( old_instance_1, domain.OLD_INSTANCE_TYPE) old_instance_2_quads = aol_mod.instance_to_quads( old_instance_2, domain.OLD_INSTANCE_TYPE) dative_app_quads = aol_mod.instance_to_quads( dative_app, domain.DATIVE_APP_TYPE) old_service_quads = aol_mod.instance_to_quads( old_service, domain.OLD_SERVICE_TYPE) quads = ( old_instance_1_quads + old_instance_2_quads + dative_app_quads + old_service_quads) aol = [] for quad in quads: aol = aol_mod.append_to_aol(aol, quad) domain_entities = { 'old-instances': set([old_instance_1, old_instance_2]), 'dative-apps': set([dative_app]), 'old-services': set([old_service]), } return aol, domain_entities